我有以下的JSON字符串
{
"property1" : "value",
"property2" : 2,
"property3" : { "subprperty1" : "value" }
}
我希望能够反序列化它(使用Newtonsoft的Json.net),但仍将property3保留为字符串。
因此,我创建了以下模型类:
class JsonModel {
string property1 {get; set;}
int property2 {get; set;}
string property3 {get; set;}
}
但是,当我使用 JsonConvert.DeserializeObject<JsonModel>(json_string);
进行反序列化时,我会得到以下错误:
Newtonsoft.Json.JsonReaderException: 'Unexpected character encountered while parsing value: {.
property3
是一个 JSON 对象而不是一个字符串。关于content/structure of prop3 is different for every call.
你的意思是什么? - D-Shih