asp.net - How to parse nested JSON string using .NET -


i'm trying parse nested json string returned gcm (google messaging) server using vb.net. json string looks this:

{ "multicast_id": 216,   "success": 3,   "failure": 3,   "canonical_ids": 1,   "results": [     { "message_id": "1:0408" },     { "error": "unavailable" },     { "error": "invalidregistration" },     { "message_id": "1:1516" },     { "message_id": "1:2342", "registration_id": "32" },     { "error": "notregistered"}   ] } 

i results array in above string.

i found following example helpful, example not show how nested parts, message_id, error , registration_id inside results array.

thanks

i'll give answer using c# , json.net

var jobj = jsonconvert.deserializeobject<response>(json); 

you can use javascriptserializer

var jobj2 = new javascriptserializer().deserialize<response>(json); 

public class result {     public string message_id { get; set; }     public string error { get; set; }     public string registration_id { get; set; } }  public class response {     public int multicast_id { get; set; }     public int success { get; set; }     public int failure { get; set; }     public int canonical_ids { get; set; }     public list<result> results { get; set; } } 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -