图片.png
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; }
}
}
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();
sontext2 .xmleixing = "支路网建设";
sontext2 .xmtype = "32";
sontext2 .count = "20";
sontext2 .url = "../ProjectManage/Pagesilding/ZongHeJiaoTong/Zonghetra/Zonghetra_List.aspx?xmtype=0101";
sontext2 .progress = "52.61";
sontext2 .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);
}
}
}
网友评论