MySQL Forums
Forum List  »  Connector/Node.js

Json output from Relational Data
Posted by: Dorian Gray
Date: June 24, 2015 03:37PM

I need to create a json output file from some data stored in a mysql table. I have downloaded MySQL Server 5.7 beta edition because it has native JSON Support, and have reviewed a lot information, but I'm not sure how to create a json output file from a query that joins 2 tables

My data is going to be coming from 2 tables 1 benefit table and a products table, and I'll need to create one json with nested array that lists each benefit.

Below is my sample data:

tbl_benefit:
Benefit:
Benefit_1
Benefit_2
Benefit_3
Benefit_4
etc.

tbl_products:
Product_ID, Benefit
1,Benefit_1
1,Benefit_2
2,Benefit_1
2,Benefit_3
2,Benefit_4
3,Benefit_2
etc.

And I need to create a simple Json output like this:
[{"product_id":"1"
"benefit":[{"benefit_1","benefit_2"}]
etc.

I would include all values in the output statement.

Options: ReplyQuote


Subject
Written By
Posted
Json output from Relational Data
June 24, 2015 03:37PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.