Guest User

Untitled

a guest
Apr 20th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. JObject o = JObject.Parse("{'People':[{'Name':'Jeff'},{'Name':'Joe'}]}");
  2.  
  3. // get name token of first person and convert to a string
  4. string name = (string)o.SelectToken("People[0].Name");
  5.  
  6. JObject o = JObject.Parse("{'People':[{'Name':'Jeff','Roles':['Manager', 'Admin']}]}");
  7.  
  8. // get role array token of first person and convert to a list of strings
  9. IList<string> names = (string)o.SelectToken("People[0].Roles").Select(t => (string)t).ToList();
Add Comment
Please, Sign In to add comment