看图:

这里可以看到是二层嵌套!!使用C#如何实现??

思路:使用list集合实现 → 建立类 → list集合 → 微软的   Newtonsoft.Json  (一款.NET中开源的Json序列化和反序列化)

sonXMText类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace JsonDemo
{
public class sonXMText
{
public string xmleixing { get; set; } public string count { get; set; } public string xmtype { get; set; } public string url { get; set; } public string progress { get; set; } public string WaitCount { get; set; }
}
}

TestInfo类

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace JsonDemo
{
public class TestInfo
{
public string XMText { get; set; } public string XMTYPE { get; set; } public string Count { get; set; } List<sonXMText> sonxmtext = new List<sonXMText>();
public List<sonXMText> sonXMText
{
get { return sonxmtext; }
set { sonxmtext = value; }
}
}
}
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace JsonDemo
{
class Program
{
static void Main(string[] args)
{
List<TestInfo> listTestinfo = new List<TestInfo>();
TestInfo testinfo = new TestInfo();
testinfo.XMText = "综合交通";
testinfo.XMTYPE = "01";
testinfo.Count = "108"; List<sonXMText> listSonText = new List<sonXMText>();
sonXMText sontext1 = new sonXMText();
sontext1.xmleixing = "市重点交通";
sontext1.xmtype = "32";
sontext1.count = "20";
sontext1.url = "../ProjectManage/Pagesilding/ZongHeJiaoTong/Zonghetra/Zonghetra_List.aspx?xmtype=0101";
sontext1.progress = "52.61";
sontext1.WaitCount = "27"; sonXMText sontext2 = new sonXMText();
sontext1.xmleixing = "支路网建设";
sontext1.xmtype = "32";
sontext1.count = "20";
sontext1.url = "../ProjectManage/Pagesilding/ZongHeJiaoTong/Zonghetra/Zonghetra_List.aspx?xmtype=0101";
sontext1.progress = "52.61";
sontext1.WaitCount = "27"; listSonText.Add(sontext1);
listSonText.Add(sontext2);
testinfo.sonXMText = listSonText; listTestinfo.Add(testinfo); string aa = Newtonsoft.Json.JsonConvert.SerializeObject(listTestinfo);
File.AppendAllText(@"C:\mymiao.txt", aa, Encoding.UTF8); }
}
}

来源:https://www.cnblogs.com/panmy/p/5924324.html

 

C# json反序列化 对象中嵌套数组 (转载)的更多相关文章

  1. C# json反序列化 对象中嵌套数组 (转载) 可能会导致循环或多重级联路径。请指定 ON DELETE NO ACTION 或 ON UPDATE NO ACTION,或修改其他 FOREIGN KEY 约束。

    C# json反序列化 对象中嵌套数组 (转载)   看图: 这里可以看到是二层嵌套!!使用C#如何实现?? 思路:使用list集合实现 → 建立类 → list集合 → 微软的   Newtonso ...

  2. struts2:遍历自定义字符串数组,遍历Action实例所引用对象中的数组

    在struts2:OGNL表达式,遍历List.Map集合:投影的使用一文中已经讲述了OGNL遍历List.Map集合等功能. 本文简单写一个遍历数组的示范程序. 1. 遍历自定义字符串数组 < ...

  3. 如何向java后台的对象中传数组

    1.后台对象的参数需要是是list对象 /* * copyright : GLOBALROAM Ptd Ltd * VmCreateInfo.java * Author: * zhangpengyan ...

  4. json反序列化对象

    这个是同事研究的wcf中中根据type类型反序列化json的示例 /// <summary> /// json转对象 /// </summary> /// <param ...

  5. 使用jQuery+huandlebars遍历展示对象中的数组

    兼容ie8(很实用,复制过来,仅供技术参考,更详细内容请看源地址:http://www.cnblogs.com/iyangyuan/archive/2013/12/12/3471227.html) & ...

  6. PHP将json或对象转成数组

    今天老大突然给了我一个小任务,给我一个txt文件,里边是很多的json字串,要求将这些字串转换成php中的数组: 于是开足火力,用了将进5分钟的时间完成了任务,代码如下: $jsonStr = fil ...

  7. C# json对象中包含数组对象时,如何存入数据库

    前端创建的的对象例如: C#端这样将数组提取出来存入

  8. 向json对象中添加数组

    // JSONArray jsonArray = new JSONArray();// for (int i = 0; i < list.size(); i++) {// JSONObject ...

  9. eval()解析json以及js中js数组、对象与json之间的转换

    http://www.cnblogs.com/myjavawork/articles/1979279.html https://www.cnblogs.com/coder-economy/p/6203 ...

随机推荐

  1. 算法竞赛新编??---WERTYU,UVa10082

    P47 例题:3-2  WERTYU,UVA10082 注:作者的想法是找出输入字符在常量数组中的位置(使用for( i = 1; s[i] && s[i] != c;i++);语句来 ...

  2. windows 函数

    数组清零 ::ZeroMemory(首地址,大小);

  3. Alpha冲刺 (2/10)

    Part.1 开篇 队名:彳艮彳亍团队 组长博客:戳我进入 作业博客:班级博客本次作业的链接 Part.2 成员汇报 组员1(组长)柯奇豪 过去两天完成了哪些任务 学习并配置了ssm框架(用于前后端交 ...

  4. git & github 同步文件

    step1 : 在github上建立一个 repository https://github.com/ntu-juking/softwaretesting.git repository name is ...

  5. 参数签名ascii码排序的坑

    参数签名中通常是按键值对中键名称的ASCII按从小到大的顺序排序后进行hash为签名字符串.不要直接使用 SortedDictionary<string, string> 有坑的,他是按数 ...

  6. IDEA tomcat 热部署不生效的问题

  7. 二进制加法Java实现

    二进制整数的Java实现 任意两个二进制数(不论在什么位置)相加,只可能出现4种情况.它们是: 0+0=0 1+0=0+1=1 1+1=10=0+向高一位的进位1 1+1+1=11=1+向高一位的进位 ...

  8. Java 命令行启动时指定配置文件目录

    java -jar -Xbootclasspath/a:/home/tms/conf    /home/tms/bin/S17-tms.jar 先指定配置文件目录: 再指定jar包路径: 运行clas ...

  9. win10 插入16k采样的耳机无法播放和录音的问题定位

    平时做智能耳机,需要经常在windows上测试不同采样率的声音信号.可是,最近在16k双声道输入的情况下, 无论系统都使用该耳机进行播放,该问题思索了好久,一直没有解决办法. 今天无意中使用了wind ...

  10. python中除法的注意事项

    使用python数据处理,代码如下: import numpy as np fs = 5 ts = np.arange(-1,1+1/fs,1/fs) 发现了这样一个错误: Traceback (mo ...