Extract values from JSON string c# Extract values from JSON string c# json json

Extract values from JSON string c#


Try this:

JavaScriptSerializer serializer = new JavaScriptSerializer();var jsonObject= serializer.Deserialize(json_object);

You can look here for more information:

JavaScriptSerializer.Deserialize - how to change field names


parse it into a dictionary using something like Newtonsoft.Once deserilized ,loop the way you want.

After the comment in the above question,dictionary might have to be replaced by a data structure where your duplicates are allowed.


So it's not buried in the comments:

In my JS, I ended up just looping through my data object:

for(i=0;i<r['data'].length,i++) {    newObject[i] = r['data'][i][0];}return JSON.stringify(newObject);

I then used JObject & JArray from the JSON.Net/newtonsoft library. Finally, I looped through my JArray to create an ObservableCollection that I bound to my ListBox ItemsSource.

Scott