gergelyke
gergelyke

Reputation: 1

Windows phone 7 json .net

i have the following response from appengine :

{"status":"OK",

  "results":[{

    "field1":"ee2",
    "field2":"ee",
    "field3":0.0,
    "field4":0.0,
    "field5":1990,
    "field6":"dd"}]
}

where results is an array.

i would like to parse this into a ObservableCollection using Newtonsoft.Json. Can you help me how to do this ?

Upvotes: 0

Views: 1041

Answers (3)

Mustafa Ekici
Mustafa Ekici

Reputation: 7470

 dynamic Results = new Uri(url).GetDynamicJsonObject();

        foreach (var result in Results.results)
        {                
            string str = result.field1;

            //add to ObservableCollection list 
        }             

Upvotes: 1

Netlight_Mobile
Netlight_Mobile

Reputation: 194

You can try something like this:

var jObject = JObject.Parse(data); //where data is your json response data
var token = jObject.SelectToken("result");
var children = token.Children();
foreach(var child in children)
{
    // Do something with your data
    string field1 = (string)child.SelectToken("field1");

}

Hope it helps! Cheers, /Anders

Upvotes: 1

Vikram
Vikram

Reputation: 8333

i hope this might help: http://www.smallandmighty.net/blog/more-json-with-windows-phone

Upvotes: 2

Related Questions