I need to get some info from json files like this: mcmodfile:
{
"modListVersion": 2,
"modList": [{
"modid": "FloatingRuins",
"name": "FloatingRuins",
"description": "Floating islands taken from the ground with ruins on top.",
"version": "1.7.10.r01",
"mcversion": "1.7.10",
"url": "http://www.minecraftforum.net/topic/1009577-/",
"updateUrl": "",
"authorList": [ "DaftPVF", "bspkrs" ],
"credits": "Original by DaftPVF",
"logoFile": "",
"screenshots": [ ],
"parent": "",
"requiredMods": [ "bspkrsCore@[6.12,)" ],
"dependencies": [ "bspkrsCore@[6.12,)" ],
"dependants": [ ],
"useDependencyInformation": "true"
}]
}
I need the "ModListVersion", "mcversion", "version", "name" and "modid".
I made a class:
{
class mcmod2
{
[JsonProperty("modListVersion")]
public int modListVersion;
[JsonProperty("modList")]
public DataRow modList;
}
}
I tried to get the data with the following code:
String json;
using (StreamReader r = new StreamReader(mcmodfile))
{
json = r.ReadToEnd();
}
mcmod2 modinfo2;
modinfo2 = JsonConvert.DeserializeObject<mcmod2>(json);
However i get the following error when I try to deserialize the file: http://paste.ubuntu.com/8071687/
Note I have no way of changing the Json, it will have to stay as is.
I tried implementing the following: How do I deserialize a JSON array and ignore the root node? Didn't help