C# winform json字符串转对象问题

qq_17275555 2017-06-13 10:07:36
JSON字符串信息如下:
"{\"cardBo\":{\"carshipnos\":[{\"cardid\":\"B99QJF297C10\",\"carshipno\":\"苏BC8Z58\",\"createdby\":\"1\",\"createddate\":\"2017-06-01 15:24:14\",\"custid\":\"psm\",\"deltag\":\"0\",\"domain\":\"\",\"id\":\"07mM1U297C10\",\"lastmodifiedby\":\"1\",\"lastmodifieddate\":\"2017-06-01 15:24:14\"},{\"cardid\":\"B99QJF297C10\",\"carshipno\":\"苏BC8Z57\",\"createdby\":\"1\",\"createddate\":\"2017-06-12 17:19:17\",\"custid\":\"psm\",\"deltag\":\"0\",\"domain\":\"\",\"id\":\"Gt24TF1Q3D10\",\"lastmodifiedby\":\"1\",\"lastmodifieddate\":\"2017-06-12 17:19:17\"},{\"cardid\":\"B99QJF297C10\",\"carshipno\":\"苏BC8Z59\",\"createdby\":\"1\",\"createddate\":\"2017-06-12 17:19:02\",\"custid\":\"psm\",\"deltag\":\"0\",\"domain\":\"\",\"id\":\"o04SG11Q3D10\",\"lastmodifiedby\":\"1\",\"lastmodifieddate\":\"2017-06-12 17:19:02\"}],\"iccard\":{\"cardno\":\"be e8 4c 5d \",\"companyid\":\"1m688STP2910\",\"createdby\":\"1\",\"createddate\":\"2017-06-01 15:23:59\",\"custid\":\"psm\",\"deltag\":\"0\",\"domain\":\"\",\"id\":\"B99QJF297C10\",\"lastmodifiedby\":\"1\",\"lastmodifieddate\":\"2017-06-01 15:23:59\",\"remarks\":\"\",\"status\":\"INUSE\"}},\"arrangements\":[],\"company\":{\"bindmessagenumber\":\"13311111111\",\"companyname\":\"无锡公司\",\"contactnumber\":\"13311111111\",\"contactperson\":\"张三\",\"createdby\":\"1\",\"createddate\":\"2017-04-23 14:55:17\",\"custid\":\"psm\",\"deltag\":\"0\",\"domain\":\"\",\"id\":\"1m688STP2910\",\"lastmodifiedby\":\"1\",\"lastmodifieddate\":\"2017-04-23 14:55:17\",\"remarks\":\"备注\",\"subsidiarycompany\":\"无锡公司下属单位\"},\"command\":{\"arrangementid\":\"\",\"cardid\":\"\",\"carshipno\":\"\",\"createdby\":\"\",\"createddate\":\"\",\"custid\":\"\",\"deltag\":\"\",\"domain\":\"\",\"id\":\"\",\"indate\":\"\",\"lastmodifiedby\":\"\",\"lastmodifieddate\":\"\",\"outdate\":\"\",\"remarks\":\"\"},\"status\":\"1\"}\r\n"

下面是我的对象信息:
//计划信息实体类
public class Projectinformation
{

public List<cardBo> cardBo { get; set; }//车辆对象信息

public List<arrangements> arrangements { get; set; }//计划信息

public company company { get; set; }//客户信息

public command command { get; set; }//未知

public int status { get; set; } //请求状态
}

//车辆信息对象
public class cardBo
{
public string cardid { get; set; }//id
public string carshipno { get; set; }//车船号
public string createdby { get; set; }//
public string createddate { get; set; }
public string custid { get; set; }
public string deltag { get; set; }
public string domain { get; set; }
public string id { get; set; }
public string lastmodifiedby { get; set; }
public string lastmodifieddate { get; set; }

}

//计划信息
public class arrangements
{
public string id { get; set; }
public string productid { get; set; }
public string companyid { get; set; }
public string arrangementdate { get; set; }
public int quantity { get; set; }
public int usedquantity { get; set; }
public string status { get; set; }
public string remarks { get; set; }
public string custid { get; set; }
public string domain { get; set; }
public string createdby { get; set; }
public string createddate { get; set; }
public string lastmodifiedby { get; set; }
public string lastmodifieddate { get; set; }
public string deltag { get; set; }
public string companyname { get; set; }
public string productname { get; set; }
}

//客户信息实体类
public class company
{
public string bindmessagenumber { get; set; }
public string companyname { get; set; }
public string contactnumber { get; set; }
public string contactperson { get; set; }
public string createdby { get; set; }
public string createddate { get; set; }
public string custid { get; set; }
public string deltag { get; set; }
public string domain { get; set; }
public string id { get; set; }
public string lastmodifiedby { get; set; }
public string lastmodifieddate { get; set; }
public string remarks { get; set; }
public string subsidiarycompany { get; set; }
}


//未知
public class command
{
public string arrangementid { get; set; }
public string cardid { get; set; }
public string carshipno { get; set; }
public string createdby { get; set; }
public string createddate { get; set; }
public string custid { get; set; }
public string deltag { get; set; }
public string domain { get; set; }
public string id { get; set; }
public string indate { get; set; }
public string lastmodifiedby { get; set; }
public string lastmodifieddate { get; set; }
public string outdate { get; set; }
public string remarks { get; set; }
}


大家看看 改如何转换?谢谢!
...全文
427 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
qq_17275555 2017-06-13
  • 打赏
  • 举报
回复
谢谢 各位 完成了! 问题还是出在 我对象信息没有处理好! 结帖 领分
by_封爱 版主 2017-06-13
  • 打赏
  • 举报
回复
先去http://www.bejson.com/ 把你的"json"扔上面看是否合法. 合法之后 在去http://json2csharp.com/把json转换成class. 然后在使用类库 反序列化就行了....
qq_17275555 2017-06-13
  • 打赏
  • 举报
回复
以下是返回信息:
xdashewan 2017-06-13
  • 打赏
  • 举报
回复
json里carshipnos,你的类里完全没有体现
正怒月神 2017-06-13
  • 打赏
  • 举报
回复
你的 json格式好像有问题

110,535

社区成员

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

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

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