【发布时间】:2022-08-02 20:07:13
【问题描述】:
我想要这个 json :
{
\"foo \": {
\"bar\": 5
}
}
要在此类中反序列化:
class MyClass
{
int foo;
}
像这样 :
void MyFunction(string _JSON)
{
string json = _JSON;
//json == {\"foo \": {\"bar\": 5}}
MyClass c = JsonConvert.Deserialized<MyClass>(json);
//c.foo == 5
}
-
为什么不直接将类结构与 JSON 结构相匹配?