嵌套 Json 解析为 c#(控制台应用程序)
Nested Json Parsing to c#(Console Application)
我需要将 Json 解析为 C#(控制台应用程序),还需要在数据表中查看解析后的数据。
据我所知,我已尝试生成 类。
代码:
{
"RLC": [
{
"PAR": ""
},
{
"PAR": ""
},
{
"PAR": ""
}
],
"PR":
请大家帮忙
您可以使用下面的 c# class 序列化 json
// Root myDeserializedClass = JsonConvert.DeserializeObject<Root>(myJsonResponse);
public class RecordLocator
{
public string PNR { get; set; }
}
public class PNRAmount
{
public string BalanceDue { get; set; }
public string AuthorizedBalanceDue { get; set; }
public string SegmentCount { get; set; }
public string PassiveSegmentCount { get; set; }
public string TotalCost { get; set; }
public string PointsBalanceDue { get; set; }
public string TotalPointCost { get; set; }
public List<object> AlternateCurrencyCode { get; set; }
public string AlternateCurrencyBalanceDue { get; set; }
}
public class Root
{
public List<RecordLocator> RecordLocator { get; set; }
public PNRAmount PNRAmount { get; set; }
}
我需要将 Json 解析为 C#(控制台应用程序),还需要在数据表中查看解析后的数据。
据我所知,我已尝试生成 类。
代码:
{
"RLC": [
{
"PAR": ""
},
{
"PAR": ""
},
{
"PAR": ""
}
],
"PR":
请大家帮忙
您可以使用下面的 c# class 序列化 json
// Root myDeserializedClass = JsonConvert.DeserializeObject<Root>(myJsonResponse);
public class RecordLocator
{
public string PNR { get; set; }
}
public class PNRAmount
{
public string BalanceDue { get; set; }
public string AuthorizedBalanceDue { get; set; }
public string SegmentCount { get; set; }
public string PassiveSegmentCount { get; set; }
public string TotalCost { get; set; }
public string PointsBalanceDue { get; set; }
public string TotalPointCost { get; set; }
public List<object> AlternateCurrencyCode { get; set; }
public string AlternateCurrencyBalanceDue { get; set; }
}
public class Root
{
public List<RecordLocator> RecordLocator { get; set; }
public PNRAmount PNRAmount { get; set; }
}