一、JSON序列化一个集合
1.序列化集合films
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
namespace JSONDemo
{
class Program
{
static void Main(string[] args)
{
List<string> films = new List<string>
{
"SPEED 7",
"HAPPY FEET",
"ICE AGE 2"
};
string json = JsonConvert.SerializeObject(films);
Console.WriteLine(json);
}
}
}
2.序列化后的结果
二、反序列化JSON成一个集合
1.反序列化JSON成一个List<string>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Newtonsoft.Json;
namespace JSONDemo
{