我试图反序列化一个包含Dictionary<string,bool>
作为条目之一的C#Dictionary<string,object>
。代码生成/序列化文件很好,但是当它加载它时,我得到以下错误。NewtonSoft.Json,无法反序列化字典中的子字典
Unable to cast object of type 'Newtonsoft.Json.Linq.JObject' to type 'System.Collections.Generic.Dictionary`2[System.String,System.Boolean]
一直试图弄清楚现在几个小时,经过大量的谷歌搜索,我似乎无法弄清楚。源文件有点大,所以我会在下面链接它们,而不是发布完整的文件。
的代码示数在这个类中获取函数的返回调用, https://gitlab.com/XerShade/Esmiylara.Online/blob/alpha-2-dev/source/Esmiylara.Frameworks/ConfigurationFile.cs
这里是我用来测试的ConfigurationFile类参考调试配置类。 https://gitlab.com/XerShade/Esmiylara.Online/blob/alpha-2-dev/source.debug/Esmiylara.Debug/DebugConfig.cs
任何帮助将不胜感激。
编辑:这是生成的JSON文件,以防万一需要看到它。
{
"RandomStringValue": "Some profound text will appear here!",
"RandomBooleans": {
"Player 1": false,
"Player 2": false,
"Player 3": false,
"Player 4": false
}
}
你可以张贴JSON数据 – Ramakrishnan
JSON文件中的数据是存在的,还是你想我跑的代码,并抢完整的错误信息? – XerShade