Skip to content

Instantly share code, notes, and snippets.

@corymartin
Created August 8, 2012 20:15
Show Gist options
  • Select an option

  • Save corymartin/3298227 to your computer and use it in GitHub Desktop.

Select an option

Save corymartin/3298227 to your computer and use it in GitHub Desktop.
Parsing JSON array in C# :/
string json = null;
using (var sr = System.IO.File.OpenText("/path/to/persons.json")) {
json = sr.ReadToEnd();
}
var serializer = new System.Web.Script.Serialization.JavaScriptSerializer();
Person[] users = serializer.Deserialize<Person[]>(json);
public class Person {
public string name { get; set; };
public byte age { get; set; };
}
[
{
"name": "Ted",
"age": 34
},
{
"name": "Jen",
"age": 29
}
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment