嗨,这是我想用C#解析的JSON文件:
{
"modelParam": {
"defaultConfigFilePath": "../modelParam.json",
"actionType":[
{
"showText":
{
"feld": "input" ,
"text": "Port",
"value": 4
}
},
{
"showText":
{
"feld": "input" ,
"text": "TestTest",
"value": 78
}
}
]
}
} 有人知道如何解析/反序列化这个文件吗?
向首席执行官问好
发布于 2022-08-17 09:06:31
首先,您必须创建这个c#类。
public class Model
{
public Modelparam modelParam { get; set; }
}
public class Modelparam
{
public string defaultConfigFilePath { get; set; }
public Actiontype[] actionType { get; set; }
}
public class Actiontype
{
public Showtext showText { get; set; }
}
public class Showtext
{
public string feld { get; set; }
public string text { get; set; }
public int value { get; set; }
}之后,您可以将它反序列化(解析)到c#对象。为此:
var model =System.Text.Json.JsonSerializer.Deserialize<Model>("your json source");https://stackoverflow.com/questions/73385529
复制相似问题