- https://github.com/Fody/Costura
- https://github.com/Fody/Costura/releases
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Newtonsoft.JSON;
- using Newtonsoft.JSON.Linq;
- namespace ConsoleApp12
- {
- class Program
- {
- static void Main(string[] args)
- {
- List<Person> list = new List<Person>()
- {
- new Person(){ ID = 1, Name = "ABC" },
- new Person(){ ID = 2, Name = "XYZ" },
- };
- var result = JsonConvert.SerializeObject(list);
- JArray jArray = JArray.Parse(result);
- foreach(var item in jArray)
- {
- Console.WriteLine($"ID:{(int)item["ID"]},Name:{(string)item["Name"]}");
- }
- Console.ReadKey();
- }
- }
- class Person
- {
- public int ID { set; get; }
- public string Name { set; get; }
- }
- }
- https://cloud.tencent.com/developer/article/1054382
来源: http://www.bubuko.com/infodetail-3241085.html