【发布时间】:2018-04-20 02:23:07
【问题描述】:
我有一个如下所示的 json 字符串
{
"1ST": {
"name": "One",
"symbol": "1st"
},
"2ND": {
"name": "Two",
"symbol": "2nd"
}
}
我正在尝试将其序列化为 C# 对象。看起来它正在创建一个字典,所以我创建了以下结构
public class Response
{
public Dictionary<string, Item> Objects { get; set; }
}
public class Item
{
public string name { get; set; }
public string symbol { get; set; }
}
在序列化过程中运行以下
response = JsonConvert.DeserializeObject<Response>(jsonString);
它不会在反序列化时引发错误,但我的响应只是返回为空。我错过了什么?
【问题讨论】:
标签: c# json json.net json-deserialization