C# Can';无法理解/查找Unity日志引用的JSON配置文件中的错误

C# Can';无法理解/查找Unity日志引用的JSON配置文件中的错误,c#,json,unity3d,C#,Json,Unity3d,我已经为游戏Valheim中的mod定制了这个JSON配置文件。mods使用Unity程序加载mods,并显示控制台日志,以便您在加载游戏时发现错误。我在Unity控制台中得到了这个关于文件的持续错误,但无法理解错误,也无法在文件JSON格式中找到任何错误 错误如下 [Info : BepInEx] Loading [Epic Loot 0.6.4] [Error : Unity Log] Exception: Unrecognized token at index 14451 Sta

我已经为游戏Valheim中的mod定制了这个JSON配置文件。mods使用Unity程序加载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()"
[Info:BepInEx]加载[Epic战利品0.6.4]
[错误:Unity日志]异常:索引14451处的令牌无法识别
堆栈跟踪:
fastJSON.JsonParser.ParseValue(System.Char*p)(at:0)
fastJSON.JsonParser.ParseArray(System.Char*p)(at:0)
fastJSON.JsonParser.ParseValue(System.Char*p)(at:0)
fastJSON.JsonParser.ParseObject(System.Char*p)(位于:0)
fastJSON.JsonParser.ParseValue(System.Char*p)(at:0)
fastJSON.JsonParser.ParseArray(System.Char*p)(at:0)
fastJSON.JsonParser.ParseValue(System.Char*p)(at:0)
fastJSON.JsonParser.ParseObject(System.Char*p)(位于:0)
fastJSON.JsonParser.ParseValue(System.Char*p)(at:0)
fastJSON.JsonParser.Decode(System.Type objtype)(at:0)
fastJSON.deserializer.ToObject(System.String json,System.Type类型)(位于:0)
fastJSON.deserializer.ToObject[T](System.String json)(位于:0)
fastJSON.JSON.ToObject[T](System.String JSON)(位于:0)
EpicLoot.EpicLoot.LoadJsonFile[T](System.String文件名)(位于:0)
EpicLoot.EpicLoot.InitializeConfig()(位于:0)
EpicLoot.EpicLoot.Awake()(位于:0)
游戏对象:AddComponent(类型)
BepInEx.Bootstrap.Chainloader:Start()
UnityEngine.Application:.cctor()“
这是文件


提前感谢您的帮助。

错误消息所说的是第14451个字符是错误的(从json解析器的角度来看)

这个字符索引对我没有多大帮助。因此,为了进一步探讨这个问题,我已经(在regex101链接中,单击左侧面板上的“替换”以查看没有注释的版本)。[*]

然后,我将无评论版本粘贴到一个在线页面中

输出更加精确:

第368行的分析错误: …,“权重”:1}},{“Obje” ----------------------^ 应为“,”,“]”,得到“}” 使用正确的文本编辑器(如notepad++)查找第368行,这里确实有问题:

{
“对象”:“水蛭”,
“下降”:[[0,0]、[1,65]、[2,25]、[3,10],
“战利品”:[

{“Item”:“Tier2EnchantMats”,“Weight”:1}您粘贴的文件包含
/
注释。实际的JSON规范中没有注释(即使某些解析器可能会忽略它们),因此这在技术上是无效的JSON。我建议尝试清除注释(例如使用正则表达式)然后重试。如果不使用//,我将如何格式化注释?原始文件有相同的注释,并且在加载时没有抛出该错误。抱歉,如果我听起来很无知,我在json方面的经验非常有限。啊,好的,我理解,所以您的json解析器确实接受这些
/
注释。好的,您可以忽略我上面的注释。谢谢谢谢你,我花了几个小时在这个问题上都没有用,而其他几个试图帮助解决的问题就是找不到。我会处理它,看看会发生什么,之后会更新:)@devestio如果答案对你有效,请将它标记为已接受(答案左侧列出的复选标记)