get_json how to get simple json.

1,010 views
Skip to first unread message

macieksk

unread,
Jan 27, 2014, 3:21:05 PM1/27/14
to jst...@googlegroups.com
Hi

I use jstree 3.0.0.b4 

How can i use get_json to get simple json string like this:

{
  id          : "string" // required
  parent      : "string" // required
  text        : "string" // node text
}

this is simple string / json which  can i insert into database.

$( "#target" ).click(function() {
     var v =$('#jstree2').jstree(true).get_json();
     var mytext = JSON.stringify(v);
     alert(mytext); 
});


Ivan Bozhanov

unread,
Jan 27, 2014, 6:38:31 PM1/27/14
to jst...@googlegroups.com
You can't get this (flat) version of the JSON - you can only get the one that is nested and it is done exactly as you do it in your code.

Best regards,
Ivan

Ivan Bozhanov

unread,
Jan 28, 2014, 4:50:30 AM1/28/14
to jst...@googlegroups.com
Pull the latest source - you can get flat json now.

Best regards,
Ivan

27 януари 2014, понеделник, 22:21:05 UTC+2, macieksk написа:

macieksk

unread,
Jan 28, 2014, 2:15:08 PM1/28/14
to jst...@googlegroups.com
hi again.

how can i use this "flat" json response?

i don't know how to set option for get_json() 

Ivan Bozhanov

unread,
Jan 29, 2014, 2:46:39 AM1/29/14
to jst...@googlegroups.com
Read the docs :)

.get_json('#', { 'flat' : true })

Best regards,
Ivan
Reply all
Reply to author
Forward
0 new messages