Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Tseng on Feb 25, 2008 22:21
open dhtmlx forum
how to set userdata with JSON string

I encounter some problems with loadJSONObject() method in how to construct the JSON string to include user data. As I know, the user data is perfectly supported by loadXML() via a xml tag, '<userdata>', but I don't know how to do that with loadJSONObject() and JSON string. Can someone help me out? Thank you.
Answer posted by Support on Feb 26, 2008 04:05
JSON reflect structure of XML object, so it will be

{id:0,item:[
   {id:1,text:"1111", userdata: [{ name:"some_name", content:"some_value"}] }
]}
Answer posted by oscarml on Jan 15, 2009 04:55
Hi,

I'm having problems with getuserdata + json. I've send next json:

{"item":
[
{"text":"text1",
"item":[{
"text":"text1_1"
"item":[],
"id":"4",
"userdata":[{"tel":"ddd"}]
}],
"id":"2",
"userdata":[{"tel":"ddd"}]},
}],
"id":"0"}

That prints perfectly, but when I raise
Object_Organigrama_tree.getUserData(id,"tel") it returns "undefined".
Is there any bug like in this post? http://www.dhtmlx.com/docs/products/kb/index.shtml?cat=search&page=1&q=4237&ssr=yes&s=json%20userdata
(Is the same as I'm aiming but for dhtmlxgrid)

Thanks



Answer posted by Support on Jan 15, 2009 07:35
Change userdata syntax to the 
          "userdata":[{"name":"tel","content":"ddd"}]
with such way of data declaration it will work correctly.