我有以下的Json字符串
{
"JsonValues":{
"id": "MyID",
"values": {
"value1":{
"id": "100",
"diaplayName": "MyValue1"
},
"value2":{
"id": "200",
"diaplayName": "MyValue2"
}
}
}
}
我想要将Json字符串转换为下面的类
class ValueSet
{
[JsonProperty("id")]
public string id
{
get;
set;
}
[JsonProperty("values")]
public List<Value> values
{
get;
set;
}
}
class Value
{
public string id
{
get;
set;
}
public string DiaplayName
{
get;
set;
}
}
我的反序列化代码是
JavaScriptSerializer js = new JavaScriptSerializer();
StreamReader sr = new StreamReader(@"ValueSetJsonString.txt");
string jsonString = sr.ReadToEnd();
var items = JsonConvert.DeserializeObject<ValueSet>(jsonString);
但是我在序列化后得到了null值,我该怎么解决?