JsonReaderException when performing JObject.Parse

3

When I run JObject.Parse it starts a content exception:

  

Error reading JObject from JsonReader. Current JsonReader item is not an object: StartArray. Path '', line 1, position 1.

The Json I'm trying to interpret would be:

[{
  "modid": "ExtraFood",
  "name": "Extra Food",
  "version": "1.7.10-0.7.45",
  "mcversion": "1.7.10",
  "description": "Extra Food by mincrmatt12 and dmf444. This mod will extend the amount of food that is in minecraft. We don't want you to starve yet, and we've added new midgame-lategame content.",
  "credits": "Dmf444, Mincrmatt12 and thanks to all those who helped on IRC and MCForge Forums",
  "logoFile": "assets/extrafood/EFlogo.png",
  "url": "https://github.com/TeamDmfMM/Extra-Food",
  "updateUrl": "",
  "authorList": ["mincrmatt12", "dmf444"],
  "parent": "",
  "screenshots": [],
  "dependencies": ["mod_MinecraftForge"]
}]
    
asked by anonymous 10.12.2015 / 00:44

1 answer

3

You have to use JArray.

JArray v = JArray.Parse(s);

With it will get a json that is a collection.

You can get the item like this:

var item = v[0]["modid"].ToString();

And so it goes.

Or you can remove the [] from the beginning and end

    
10.12.2015 / 00:51