序列化列表<Dictionary<String,Object>>
Serialise List<Dictionary<String,Object>>
我有一个字典列表,我想在 c#Json 中序列化
protected List<Dictionary<String, Object>> Details;
我想在另一个处理程序中反序列化这个字典列表,有什么建议吗?
您可以使用 JSON.net 轻松完成此操作。这是一个例子:
List<Dictionary<String, Object>> Details = new List<Dictionary<string, object>>
{
new Dictionary<string,object>
{
{"abc" , "def"},
{"123", 234}
},
new Dictionary<string,object>
{
{"abc1" , "def1"},
{"1231", 2341}
}
};
// serializing to: [{"abc":"def","123":234},{"abc1":"def1","1231":2341}]
string json = JsonConvert.SerializeObject(Details);
// de-serializing to a new List<Dictionary<String, Object>>.
List<Dictionary<String, Object>> newDic = JsonConvert.DeserializeObject<List<Dictionary<String, Object>>>(json);
我有一个字典列表,我想在 c#Json 中序列化
protected List<Dictionary<String, Object>> Details;
我想在另一个处理程序中反序列化这个字典列表,有什么建议吗?
您可以使用 JSON.net 轻松完成此操作。这是一个例子:
List<Dictionary<String, Object>> Details = new List<Dictionary<string, object>>
{
new Dictionary<string,object>
{
{"abc" , "def"},
{"123", 234}
},
new Dictionary<string,object>
{
{"abc1" , "def1"},
{"1231", 2341}
}
};
// serializing to: [{"abc":"def","123":234},{"abc1":"def1","1231":2341}]
string json = JsonConvert.SerializeObject(Details);
// de-serializing to a new List<Dictionary<String, Object>>.
List<Dictionary<String, Object>> newDic = JsonConvert.DeserializeObject<List<Dictionary<String, Object>>>(json);