Click here to Skip to main content
15,888,461 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
"paxs": [
    {
      "type": "Adult",
      "count": 12
    },
    {
      "type": "Child",
      "count": 0
    },
    {
      "type": "Infant",
      "count": 0
    }
  ],



I Have part of json like this, How can I deserialize this. Now I am using
C#
JsonConvert.DeserializeObject

to convert it but it is giving me exception because it is of list type and json convert list into brackets like that.Any help. thanks
Posted

1 solution

It denotes an array.

If you have a class like :
C#
private class pax{
  public string type {get;set;}
  public int count {get;set;}
}

then you can deserialize to an array of this called paxs:
C#
private class myObject{
  public pax[] paxs {get;set;}
}

//...

myObject mo = JsonConvert.DeserializeObject<myobject>(jsonString);
</myobject>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900