How do I get the value inside a value in JSON with VB.NET -
i using visual studio 2010 , coding in visual basic. have json file , read through , can name , value of item. cannot name , value of item inside value of item. can "page-1.htm" , in braces "page-1.htm", cannot "title" or "safety". know can "safety" if know "title" there item("title").value, can see items have title , have numbers cannot info out way.
here json
{ "page-1.htm":{ "title": "safety", "001": "1. purpose", "002": "2. definitions" }, "page-2.htm":{ "title": "testing", "001": "test first", "002": "test again", "003": "final test" }, "page-3.htm":{ "title": "once again" } }
here start of vb
try dim reader = new streamreader(jsonfile.tostring()) dim rawresp string = reader.readtoend() dim jresults jobject = jobject.parse(rawresp) dim results list(of jtoken) = jresults.children().tolist() each item jproperty in results 'this works , gives me nodes in treeview dim rootname string = item.name dim root treenode = tvcontent.nodes.add(rootname) 'this not work add child nodes because can't info need '"inside value" "safety" or "1. purpose", or "2. etc" json dim childnode treenode = tvcontent.nodes(0).nodes.add("inside value") next catch ex exception messagebox.show(ex.message) end try
try this:
for each child in item.children each value in child.values root.nodes.add(value.tostring) next next
to both, name , value, need @ jproperties
.
for each child in item.children each jprop jproperty in child root.nodes.add(string.format("{0} = {1}", jprop.name, jprop.value)) 'or 'root.nodes.add(jprop.tostring) next next
Comments
Post a Comment