Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSON.net deserialize JSON without schema

I have some JSON:

{
    "739c39e": [7866679, 31.96051, 117.13700, 310, 30100, 408, 20515, 2955, "A319", "B-6429", 1440504861, "SHA", "XIY", "MU2168", 0, 0, "CES2168", 0],   
    "739d433": [5242971, 51.46741, -0.48536, 270, 0, 16, 0, 2529, "A320", "T7-MRD", 1440504861, "LHR", "BEY", "ME202", 1, 0, "MEA202", 0]
}

I am trying to deserialize this, but am not having much luck.

I've tried:

 var definition = new { a = "", b = "", c = "", d = "", e = "", f = "", g = "", h = "", i = "", j = "", k = "", l = "", m = "", n = "", o = "", p = "", q = "", r = "" };
 var jsonData = @File.ReadAllText(@filepathToData);
 dynamic deserializedData = JsonConvert.DeserializeAnonymousType(jsonData, definition);

I never expected that to work, really, as there is no "definition" in the JSON. I have also tried the JArray.Parse(jsonData); way, but I get nothing.

I've also tried JsonConvert.DeserializeObject(jsonData); but that does not return anything... or at least I am unable to inspect the returned object with Visual Studio (2015).

Does anyone have any ideas?

I'm doing this in Unity3D, if it makes any difference.

like image 461
pookie Avatar asked Feb 15 '26 04:02

pookie


1 Answers

You can try this

var o = JsonConvert.DeserializeObject<Dictionary<string, object[]>>(json);
o.Dump();
like image 91
panshu Avatar answered Feb 17 '26 16:02

panshu



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!