Created
April 4, 2014 06:38
-
-
Save deostroll/9969331 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} | |
} | |
} |
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
thanks a lot