• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to store nested JSON data in MYSQL database  RSS feed

 
surya preethaaa
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have more than 25,000 headwords for d3...that is almost 25,000 set of json..i want to save datas into mysql database and retrieve in json format which i will use in d3..
i dont know how should i store the nested json data into mysql to access it...it will be better if datas in a single table...but no idea,how to use the table for nested json values..
i just used here a sample nested json...how should i store the data in mysql to access it

sample nested JSON
 
Swastik Dey
Rancher
Posts: 1812
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ideally your first step should be to parse the json and store in a java class , then think about storing it in db.
 
surya preethaaa
Ranch Hand
Posts: 139
 
Swastik Dey
Rancher
Posts: 1812
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Probably yes.   There are lot of  ways to parse json
 
surya preethaaa
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i used this tool

and the generated java class is

 
Paul Clapham
Sheriff
Posts: 22509
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Okay... but your question is ambiguous. Do you have a database design already set up to contain that data, and you're bogged down in figuring out how to output the data to that database? Or are you confused about how to design a database to contain that data?
 
surya preethaaa
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually,i have one table where some of the rows are null..

PARENT        CHILD1          CHILD2             CHILD3
paren      c1         c11
paren      c1          c12
paren      c1          c12                  c121
paren      c2          c21
paren      c2          c22
paren      c2          c23

when i use jsp to retrieve the data from the table and display in the json format ..IT gives me the output


@Swastik  suggest me to do this with SERVLET..i am new to servlet,so felt difficult to use servlet..thats why i tried to modify the table ,to see whether i get my required json format or not
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66207
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does it really need to be broken down? Will you be joining on the columns? Or do you just need to store and retrieve the text? Why not just store it as a text blob?
 
surya preethaaa
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my required json is ,what i posted in the question..i want to get it without broken..i mean
one common parent
children
sub children

i tried to use JSON OBJECT now

to get output in json format..
i get valid json


but totally wrong when compare with my requirement..
 
surya preethaaa
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want nested json format from mysql database which i will use in d3 further
 
surya preethaaa
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
any suggestion for the problem i stated or a way to iterate thro mysql to avoid null in json and to have
common parent
                children
                          subchildren
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!