我已经为Valheim游戏中的mod自定义了这个JSON配置文件。mods使用Unity程序来加载mods,它会显示一个控制台日志,这样你就可以在加载mods时发现错误。我在Unity控制台中得到了关于该文件的持续错误,但无法理解该错误,也无法在文件的JSON格式中找到任何错误。
错误如下
[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()"这是文件
提前感谢您的帮助。
发布于 2021-04-04 01:36:01
错误消息所说的是第14451个字符是错误的(从json解析器的角度来看)。
这个字符索引对我没有多大帮助。因此,为了进一步探索这一点,我使用了removed the comments with a regex (在regex101链接中,单击左侧面板上的“替换”以查看没有注释的版本)。*
然后,我将无注释版本粘贴到一个在线JSON parser中。
输出更精确一点:
Parse error on line 368:
..., "Weight": 1 } }, { "Obje
----------------------^
Expecting ',', ']', got '}'通过使用像notepad++这样的正确文本编辑器找到第368行,确实存在一些问题:
{
"Object": "Leech",
"Drops": [ [0, 0], [1, 65], [2, 25], [3, 10] ],
"Loot": [
{ "Item": "Tier2EnchantMats", "Weight": 1 } <--- line 368 without the comments
},在我看来,你想要的是:
{
"Object": "Leech",
"Drops": [ [0, 0], [1, 65], [2, 25], [3, 10] ],
"Loot": [
{ "Item": "Tier2EnchantMats", "Weight": 1 }
]
},你忘了关闭数组'Loot‘!(需要右括号)
我将让您重复此过程以检查其他语法错误。
注意:*尽管一些JSON解析器可以容纳注释,但JSON规范根本没有授权它们,就像这个解析器一样。
https://stackoverflow.com/questions/66933866
复制相似问题