I'm trying to get an array out of some JSON code.
Which I get from here: JSON code source
I have this, but I have no idea how to make the output usable.
//Some other code above this line
var jsonout = new JavaScriptSerializer().Deserialize<List<Rootobject>>(json);
}
}
//JSON structure
public class Rootobject
{
public Class1[] Property1 { get; set; }
}
public class Class1
{
public string group { get; set; }
public string tracker { get; set; }
public string measureTime { get; set; }
public int minAgo { get; set; }
public float lat { get; set; }
public float lon { get; set; }
public History[] history { get; set; }
}
public class History
{
public float lat { get; set; }
public float lon { get; set; }
public int minAgo { get; set; }
}
I have no idea how to to get the lat, lon, measureTime, etc.. from the output. Do you guys a nice way on how to do it? (I'm very new with using JSON in C#).
JavaScriptSerializerrather than (say) Json.NET? What does your current code actually do? (It looks like you should be deserializing aList<Class1>, not aList<Rootobject>.)Class1is unnecessary. Post your JSON to json2csharp.com and you can get a corrected data model, whereRootObjecthas the properties fromClass1.