[英]How to get all properties or fields from JObject
I can't find any solution for my case.I recieve JSON and then I parsed it to my class Instance.In the instance I have property object Model that must be maped from JSON object model.All is good but in this model I don't know how many and which property I can recieve. I can't find any solution for my case.I recieve JSON and then I parsed it to my class Instance.In the instance I have property object Model that must be maped from JSON object model.All is good but in this model I don不知道我能收到多少和哪些财产。 I want to iterate all props in model and check theirs type.I need this because I want to generate EditForm from model properties.I was tried with我想迭代 model 中的所有道具并检查他们的类型。我需要这个因为我想从 model 属性生成 EditForm。我试过了
foreach(PropertyInfo prop in Model.GetType().GetProperties())
but it looks the model is type of NewtonSoft.Json.Linq.JObject.但看起来 model 是 NewtonSoft.Json.Linq.JObject 的类型。
class Instance
{
public object Model { get; set; }
public List<Label> Labels { get; set; }
public List<Instance> Children { get; set; }
}
I found a solution for this problem.我找到了解决这个问题的方法。 All is in my JSON file structure.一切都在我的 JSON 文件结构中。 I maked model him like this:我像这样制作了 model 他:
model:[ {"key":"someKey","value":"someValue"}]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.