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

qq_17275555 qq_17275555 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
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; }
}


大家看看 改如何转换?谢谢!
...全文

相关推荐

HTTP Post提交Json与接收返回结果 Winform程序

HTTP Post提交与接收Json Winform程序,实现Json的提交和接收

jinlingyuhua

c#中字符串转为json对象与json转对象

using System.Collections.Generic; using Newtonsoft.Json.Linq; using Newtonsoft.Json; using System.Web.Script.Serialization; //使用JavaScriptSerializer()方式转json,需要添加System.Web.Extensions.dll最低的frameword3.5版本才有该dll //使用JsonConvert方式需要Newtonsoft.dll;引用Newtons

勿在浮沙筑高台

C# WinForm开发JSON转Excel工具:从嵌套解析到导出实践

在软件开发与数据处理中,JSON作为轻量级数据交换格式被广泛使用,但其树状嵌套结构与Excel二维表格之间存在着天然的不匹配。理解JSON的层级关系与扁平化原理,是高效完成数据格式转换的关键。针对这一需求,通过C#与WinForm技术栈构建离线桌面工具,利用DataTable作为中间层,将嵌套对象与数组按规则映射为行列结构,再借助NPOI库生成规范的xlsx文件。该方案不仅解决了在线工具在数据量、字段嵌套和安全性方面的局限,也满足了企业内网环境下的数据转换需求。无论是接口日志解析、业务数据整理,还是批量报表

小鹅通

JSON转EXCEL文件离线安装包

JSON转EXCEL文件安装包,C#开发winform

zjxuqing

C# WinForm 解析json並寫入DataGridView

透過C# WinForm方式撰寫 更方便讓學習者學習 解析Json碼並且寫入DataGrideView中

rainchang
评论 5
收藏 已收藏
分享
返回顶部
qq_17275555
C# 111,129 成员 642,538 内容