I am very new to JSON, so I may have missed something.
(我是JSON的新手,所以我可能错过了一些东西。)
But here's what I am attempting. (但是,这就是我正在尝试的。)
I want to Deserialize the following type of JSON (我想反序列化以下类型的JSON)
{
"Size":
{
"Creature":
{
"Dragon":
[
"Huge",
"Colossal",
"Mountain-sized"
],
"Wolf":
[
"Pup",
"Fully grown",
"Giant"
]
},
"Building":
[
"Small",
"Medium",
"Large"
]
}
}
The core function of the JSON is intended so that I am not sure how nested it may become over time.
(JSON的核心功能旨在防止我随时间推移嵌套的方式。)
With creature having subtypes depending on what kind of creature it is, and same for building and so on. (对于具有根据其生物种类而定的亚型的生物,对于建筑物等也具有相同的亚型。)
I've attempted with this code
(我尝试使用此代码)
using StreamReader r = new StreamReader("Storage.json");
string json = r.ReadToEnd();
CoreStorageDict = JsonConvert.DeserializeObject<Dictionary<string, List<string>>>(json);
I would like to Deserialize it into a dictionary as directly as possible, but I've yet to find a good way to do it and I think I am missing something fundamental about the whole system.
(我想尽可能直接将其反序列化为字典,但是我还没有找到一种好的方法来完成它,而且我想我缺少整个系统的基本知识。)
Is the JSON wrong or is my code wrong?
(JSON错误还是我的代码错误?)
Or both perhaps? (还是两者都有?)
ask by Tor Nordmark translate from so 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…