asp.net - all values not coming while parsing json to string in c# -


i have j son data in string in j son response. i'm able request-id value. other coming in debugging unable retrieve dictionary type.can u tell me how other values of mobile number- date , status , description. screen shot added kindly go through http://postimg.org/image/6iad15yxl/

my j son data

{     "requestid": "546b384ce51f469a2e8b4567",     "numbers": {         "917566551111": {             "date": "2014-11-18 17:45:59",             "status": 1,             "desc": "delivered"         }     } } 

c# code

        public partial class jsontocsharp : system.web.ui.page         {             protected void page_load(object sender, eventargs e)             {          json = request.querystring["data"];                  var req = jsonconvert.deserializeobject<request>(json);                  string requestid = req.requestid;                   }         }     public class smsstatus {     public string date { get; set; }     public int status { get; set; }     public string desc { get; set; } }   public class request {     public string requestid { get; set; }     public dictionary<string, smsstatus> numbers { get; set; } //<-- see line } 

your model should this

public class smsstatus {     public string date { get; set; }     public int status { get; set; }     public string desc { get; set; } }   public class request {     public string requestid { get; set; }     public dictionary<string, smsstatus> numbers { get; set; } //<-- see line } 

now these deserializations work

var req = jsonconvert.deserializeobject<request>(json); 

or

var req = new javascriptserializer().deserialize<request>(json); 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

jquery - javascript onscroll fade same class but with different div -