Jsonreaderexception when performing Jobject.Parse

Asked

Viewed 66 times

3

When I execute JObject.Parse starts an Exception content:

Error Reading Jobject from Jsonreader. Current Jsonreader item is not an Object: Startarray. Path '', line 1, position 1.

The Json I’m trying to play 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"]
}]

1 answer

3


You have to use Jarray.

JArray v = JArray.Parse(s);

With it will catch a json q is a collection.

You can pick up the item like this:

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

And so it goes.

Or take the [ ] out of the beginning and the end

  • and in the case of authorList, the same occurs in dependencies

Browser other questions tagged

You are not signed in. Login or sign up in order to post.