求实体类:请问这样JSON格式怎么创建实体类以便将JSON转实体类!

liouqiaoa 2012-08-08 06:47:56
{"code":"0","message":{"recordtotalcount":3,"recordlistcount":3,"recordlistdetail":[{"customername":"??????","customerno":"79231842","certificateno":"1","sex":"","birthday":"","telephone":"1213","address":"????????????????????????????????????????????????"},{"customername":"??????","customerno":"79231842","certificateno":"610203198403100015","sex":"","birthday":"","telephone":"123456","address":"????????????????????????????????????????????????"},{"customername":"?????????","customerno":"79438322","certificateno":"61010419760409341X","sex":"","birthday":"","telephone":"13891921327","address":"?????????????????????6-1-2304"}]}}
...全文
211 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
胡同o 2014-06-01
  • 打赏
  • 举报
回复
借楼... 大婶们!这段json该如何写实体类呢? { "status": 1, "rule": { "1": { "id": "1", "name": "方式1", "silver": 100 }, "2": { "id": "2", "name": "方式2", "gold": "2" } }, "list": { "1": { "id": "343976", "name": "张三", "quality": "1", "level": "1", "image": "1", "type": "1", "wuli": "81", "zhili": "36", "tili": "71", "wuliup": "0", "zhiliup": "0", "tiliup": "0", "star": "1", "goout": "1", "cultivate": [] } } }
cs_esharp 2012-08-08
  • 打赏
  • 举报
回复
创建复合对象,外面用泛型接就可以了
mngzilin 2012-08-08
  • 打赏
  • 举报
回复
    class A
{
public int code;
public M message;
}
class M
{
public int recordtotalcount;
public int recordlistcount;
public List<C> recordlistdetail;

}
class C
{
public string customername;
public string customerno;
public int certificateno;
public string sex;
public string birthday;
public string telephone;
public string address;
}


A 就是了
iyomumx 2012-08-08
  • 打赏
  • 举报
回复
练手:

//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.269
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------

using System.Xml.Serialization;

//
// 此源代码由 xsd 自动生成, Version=4.0.30319.1。
//


/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
[System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)]
public partial class root {

private string codeField;

private rootMessage[] messageField;

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string code {
get {
return this.codeField;
}
set {
this.codeField = value;
}
}

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("message", Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public rootMessage[] message {
get {
return this.messageField;
}
set {
this.messageField = value;
}
}
}

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
public partial class rootMessage {

private string recordtotalcountField;

private string recordlistcountField;

private rootMessageRecordlistdetailItem[][] recordlistdetailField;

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string recordtotalcount {
get {
return this.recordtotalcountField;
}
set {
this.recordtotalcountField = value;
}
}

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string recordlistcount {
get {
return this.recordlistcountField;
}
set {
this.recordlistcountField = value;
}
}

/// <remarks/>
[System.Xml.Serialization.XmlArrayAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
[System.Xml.Serialization.XmlArrayItemAttribute("item", typeof(rootMessageRecordlistdetailItem), Form=System.Xml.Schema.XmlSchemaForm.Unqualified, IsNullable=false)]
public rootMessageRecordlistdetailItem[][] recordlistdetail {
get {
return this.recordlistdetailField;
}
set {
this.recordlistdetailField = value;
}
}
}

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
public partial class rootMessageRecordlistdetailItem {

private string customernameField;

private string customernoField;

private string certificatenoField;

private string sexField;

private string birthdayField;

private string telephoneField;

private string addressField;

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string customername {
get {
return this.customernameField;
}
set {
this.customernameField = value;
}
}

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string customerno {
get {
return this.customernoField;
}
set {
this.customernoField = value;
}
}

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string certificateno {
get {
return this.certificatenoField;
}
set {
this.certificatenoField = value;
}
}

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string sex {
get {
return this.sexField;
}
set {
this.sexField = value;
}
}

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string birthday {
get {
return this.birthdayField;
}
set {
this.birthdayField = value;
}
}

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string telephone {
get {
return this.telephoneField;
}
set {
this.telephoneField = value;
}
}

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Form=System.Xml.Schema.XmlSchemaForm.Unqualified)]
public string address {
get {
return this.addressField;
}
set {
this.addressField = value;
}
}
}

/// <remarks/>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "4.0.30319.1")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("code")]
[System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true)]
[System.Xml.Serialization.XmlRootAttribute(Namespace="", IsNullable=false)]
public partial class NewDataSet {

private root[] itemsField;

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("root")]
public root[] Items {
get {
return this.itemsField;
}
set {
this.itemsField = value;
}
}
}

110,536

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧