如何在c#中创建低于JSON值的属性?

时间:2018-04-27 10:12:23

标签: c# json properties

enter image description here如何在c#中为以下JSON值创建属性?

{
"charts":[
"CaseStatusChart",
"InvoiceStatusChart",
"QuoteStatusChart"
],
"recent_activities":[
"Accounts",
"Cases",
"Calls"
],
"counters":[
"Cases",
"Calls",
"Accounts",
"Documents"
]
}

2 个答案:

答案 0 :(得分:2)

使用json2Csharp等在线工具进行格式化,或者如果您使用的是visual studio,请按照以下步骤操作:

  1. 复制JSON打开文件
  2. 列表项
  3. 转到编辑 - 粘贴特价 - > 将JSON粘贴为类
  4. enter image description here

    JSON的类将是

    public class RootObject
    {
        public List<string> charts { get; set; }
        public List<string> recent_activities { get; set; }
        public List<string> counters { get; set; }
    }
    

答案 1 :(得分:0)

class Details 
{
    public string[] charts { get; set; }
    public string[] recent_activities { get; set; }
    public string[] counters { get; set; }

}