c# - How to get values from JSON strings using JSON.NET -


what do value's of code in both badgeindex:1 & 2?

"selectedbadges": [   {     "badgeindex":1,     "code":"cp005",     "name":"chapter 2"   },   {     "badgeindex":2,     "code":"fr092",     "name":""   } ] 

you can use this website generate c# classes json.

public class selectedbadge {     public int badgeindex { get; set; }     public string code { get; set; }     public string name { get; set; } }  public class rootobject {     public list<selectedbadge> selectedbadges { get; set; } } 

now can use: rootobject ro = jsonconvert.deserializeobject<rootobject>(json);

then can each element example: string s = ro.selectedbadges[0].code;

i hope can you.


Comments