Can't understand/find error in JSON config file referenced by Unity logs

Viewed 283

I have customized this JSON config file for a mod from the game Valheim. The mods make use of a Unity program in order to load the mods up and it shows a console log so you can find errors while loading the game with said mods. I am getting this constant error in the Unity console regarding the file, but cannot understand the error or find any errors in the files JSON formatting.

The error is as follows

[Info   :   BepInEx] Loading [Epic Loot 0.6.4]
[Error  : Unity Log] Exception: Unrecognized token at index 14451
Stack trace:
fastJSON.JsonParser.ParseValue (System.Char* p) (at <375de602811e45c183084f18a311bd14>:0)
fastJSON.JsonParser.ParseArray (System.Char* p) (at <375de602811e45c183084f18a311bd14>:0)
fastJSON.JsonParser.ParseValue (System.Char* p) (at <375de602811e45c183084f18a311bd14>:0)
fastJSON.JsonParser.ParseObject (System.Char* p) (at <375de602811e45c183084f18a311bd14>:0)
fastJSON.JsonParser.ParseValue (System.Char* p) (at <375de602811e45c183084f18a311bd14>:0)
fastJSON.JsonParser.ParseArray (System.Char* p) (at <375de602811e45c183084f18a311bd14>:0)
fastJSON.JsonParser.ParseValue (System.Char* p) (at <375de602811e45c183084f18a311bd14>:0)
fastJSON.JsonParser.ParseObject (System.Char* p) (at <375de602811e45c183084f18a311bd14>:0)
fastJSON.JsonParser.ParseValue (System.Char* p) (at <375de602811e45c183084f18a311bd14>:0)
fastJSON.JsonParser.Decode (System.Type objtype) (at <375de602811e45c183084f18a311bd14>:0)
fastJSON.deserializer.ToObject (System.String json, System.Type type) (at <375de602811e45c183084f18a311bd14>:0)
fastJSON.deserializer.ToObject[T] (System.String json) (at <375de602811e45c183084f18a311bd14>:0)
fastJSON.JSON.ToObject[T] (System.String json) (at <375de602811e45c183084f18a311bd14>:0)
EpicLoot.EpicLoot.LoadJsonFile[T] (System.String filename) (at <626516c9d3e244fa8f8ddd6519f94bb9>:0)
EpicLoot.EpicLoot.InitializeConfig () (at <626516c9d3e244fa8f8ddd6519f94bb9>:0)
EpicLoot.EpicLoot.Awake () (at <626516c9d3e244fa8f8ddd6519f94bb9>:0)
UnityEngine.GameObject:AddComponent(Type)
BepInEx.Bootstrap.Chainloader:Start()
UnityEngine.Application:.cctor()"

And here is the file

https://pastebin.com/RugHLkm0

Thank you in advance for any help.

1 Answers

What the error message is saying is that 14451th character is wrong (from the json parser's point of view).

This character index is not very helpful to me. So, to explore this further, I've removed the comments with a regex (in the regex101 link, click on "substitution" on the left panel to see the version without comments). [*]

Then I pasted the comment-less version in an online JSON parser.

The output is a bit more precise:

Parse error on line 368:
..., "Weight": 1 }    },    {      "Obje
----------------------^
Expecting ',', ']', got '}'

Find the line 368 by using some correct text editor like notepad++, and indeed there is something wrong here:

    {
      "Object": "Leech",
      "Drops": [ [0, 0], [1, 65], [2, 25], [3, 10] ],
      "Loot": [
        { "Item": "Tier2EnchantMats", "Weight": 1 }   <--- line 368 without the comments
    },

In my opinion, you wanted this instead :

    {
      "Object": "Leech",
      "Drops": [ [0, 0], [1, 65], [2, 25], [3, 10] ],
      "Loot": [
        { "Item": "Tier2EnchantMats", "Weight": 1 }
      ]
    },

You forgot to close the array 'Loot' ! (closing bracket needed)

I'll let you repeat the process to check for other syntax errors.

Note: [*] Even though some JSON parsers may accommodate comments, the JSON specifications don't authorize them at all, as for this parser.

Related