There is the next json
[{ "id": [ "11412424829" ], "o": [ 366 ], "g": 3, "l": [ "14720829159177850865" ], "c": 1, "m": "StatTrak™ AK-47 | Fire Serpent", "z": 4, "e": "FN", "u": "cm9", "p": 4271.25, "f": [ "0.06850684" ], "y": [ 4 ], "n": [ 0 ], "b": [ "76561198316800514" ], "v": 9, "h": 6 }, { "id": [ "11412545230" ], "o": [ 650 ], "g": 2, "l": [ "9803423996325074679" ], "m": "★ Karambit | Gamma Doppler Emerald", "z": 4, "e": "FN", "u": "ddb", "p": 4162.1, "f": [ "0.02687659" ], "y": [ 8 ], "n": [ "@TranceM8" ], "b": [ "76561198338195694" ], "h": 6 } ] I'm trying to translate it into class. Generated via built-in generator.
public class Rootobject { public Class1[] Property1 { get; set; } } public class Class1 { public string[] id { get; set; } public int[] o { get; set; } public int g { get; set; } public string[] l { get; set; } public int c { get; set; } public string m { get; set; } public int z { get; set; } public string e { get; set; } public string u { get; set; } public float p { get; set; } public string[] f { get; set; } public int[] y { get; set; } public object[] n { get; set; } public string[] b { get; set; } public int v { get; set; } public int h { get; set; } } Here is the final code.
JavaScriptSerializer js = new JavaScriptSerializer(); var json = File.ReadAllText("1.txt"); var rez = js.Deserialize<Rootobject[]>(json); Why Property1 elements are empty, although serialization did not cause a mistake.
Deserialize<Rootobject>- without square brackets. Because the array is inside this object. - Alexander Petrov