【发布时间】:2014-03-03 21:59:05
【问题描述】:
给定以下 JSON 对象,
form = {
"name": "",
"address": {
"street": "",
"city": "",
"province": "",
"postalCode": "",
"country": ""
},
"phoneDay": "",
"phoneCell": "",
"businessName": "",
"website": "",
"email": ""
}
什么是自动生成以下 C# 类的工具?
public class ContactInfo
{
public string Name { get; set; }
public Address Address { get; set; }
public string PhoneDay { get; set; }
public string PhoneCell { get; set; }
public string BusinessName { get; set; }
public string Website { get; set; }
public string Email { get; set; }
}
public class Address
{
public string Street { get; set; }
public string City { get; set; }
public string Province { get; set; }
public string PostalCode { get; set; }
public string Country { get; set; }
}
我们已经研究过这些问题:
Generate C# classes from JSON Schema 正在询问 JSON 模式,这可能是一种在未来可以使用的方法。
Benefits and drawbacks of generated C# classes for Json objects
【问题讨论】:
-
json2csharp.com ???
-
试试这个工具可能会有所帮助..tools4geeks.com/json-to-Csharp-classes
-
有人知道如何用 Swagger YAML 做同样的事情吗?
-
不幸的是,json2charp.com 现在是一个正在出售的域名。这太糟糕了,而且快管的有点笨重。有人知道更好的选择吗?
-
@DARKGuy jsonutils jsonutils.com
标签: c# json code-generation