我有以下 JSON
{
"employee" : {
"property1" : "value1",
"property2" : "value2",
//...
}
}
像这样的类
public class employee
{
public string property1{get;set;}
public string property2{get;set;}
//...
}
如果我需要在我的 JSON 中添加 property3,那么我也需要在我的类中进行更改。
即使我更改了 JSON(添加另一个属性,如 property3),我如何反序列化为一个类。
newtonsoft.json
等序列化/反序列化技术与类紧密耦合。
有没有更好的方法/工具在 c# 的可移植类中反序列化
这些JSON
?
最佳答案
Newtonsoft没有与强类型紧密耦合。您也可以反序列化动态类型。见类似问题here ( How to read the Json data without knowing the Key value )
关于c# - c#中JSON的反序列化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30977297/