Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save deostroll/9969331 to your computer and use it in GitHub Desktop.
Save deostroll/9969331 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
namespace caNewtonsoftJson
{
class Person
{
public string Name { get; set; }
public int Age { get; set; }
}
class Program
{
static void Main(string[] args)
{
string jsonString = @"{
type: 'Person',
data: [
{Name: 'Arun', Age: 23},
{Name: 'Jassy', Age: 33},
{Name: 'Abijit', Age: 34}
]
}";
JObject obj = JObject.Parse(jsonString);
var jarr = obj["data"].Value<JArray>();
List<Person> lst = jarr.ToObject<List<Person>>();
Console.WriteLine("{0}, {1}", lst[0].Name, lst[1].Age);
}
}
}
@jeff9571
Copy link

thanks a lot

@OskarZyg
Copy link

This came in clutch. Thanks a lot x2 <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment