c# - getting value of children -
my simple json info below
string _jsondata = @" { "tm":{ "1":{ "pl":{ "11":{ "foo":"2" }, "902":{ "foo":"70" } } } }";
i can value of pl children's foo values (such 2 , 70) below code
jobject _jobject = jobject.parse(_jsondata); foreach (jtoken _jtokencurrent in _jobject["tm"]["1"]["pl"].children()) { messagebox.show(_jtokencurrent["foo"].tostring()); }
so how can value of pl children's property values (such 11 , 902)?
thank in advance.
ok have solved below;
jobject _jobject = jobject.parse(_jsondata); foreach (jtoken _jtokencurrent in _jobject["tm"]["1"]["pl"].children()) { // values such 11 , 902 jproperty _jtokencurrentname = (jproperty)_jtokencurrent; messagebox.show(_jtokencurrentname.name); /// values such 2 , 70 messagebox.show(_jtokencurrent["foo"].tostring()); }
c# json.net
No comments:
Post a Comment