C#用字典生成json类

时间:2017-04-12 11:18:39

标签: c# json

我想问一下如何使用字典从json文件中创建一个json类。 不幸的是,我不知道班级必须如何看待。副本&粘贴生成器没有帮助。我之后如何使用它是反序列化。

提前谢谢

{
  "Keywordmask": "Packingtable",
  "Keywords": {
    "Itemnumber": "SA4F5ASD",
    "Productname": "DA51SAD",
    "Customerorder": "44SAD",
    "Productionorder": "454DSA54-002",
    "Serialnumber": "C3H3",
    "Customernumber": "30604",
    "Customer": "Horst",
    "Endcustomer": "Magret",
    "Repair": "0",
    "Repair Itemnumber": "",
    "Comment": "",
    "Patternpicture": "1",
    "Created On": "12.04.2017 11:42:04"
  }
}

1 个答案:

答案 0 :(得分:1)

public class Keywordmask
{
    public string Keywordmask { get; set; }
    public Dictionary<string, string> Keywords{ get; set; }
}

将班级名称更改为合适的名称

然后将JSON转换为C#,请尝试以下方法之一

How to Convert JSON object to Custom C# object?