namespace test
{ class Program
{
static void Main(string[] args)
{
var zoo1 = new zoo(); zoo1.animals = new List<animal>();
zoo1.animals.Add(new cat() { Name = "hello kitty", legs = });
zoo1.animals.Add(new dog() { Name = "dog1", tail = true });
string json= fastJSON.JSON.Instance.ToJSON(zoo1); //序列化
var z = fastJSON.JSON.Instance.ToObject<zoo>(json); //反序列化 Console.WriteLine(z.animals[].Name);
Console.Read();
}
} public class animal { public string Name { get; set; } }
public class cat : animal { public int legs { get; set; } }
public class dog : animal { public bool tail { get; set; } }
public class zoo { public List<animal> animals { get; set; }
}

FastJson用法-LMLPHP

https://www.cnblogs.com/hjblog/archive/2012/11/19/2776869.html

如何屏蔽对象本身的一些属性

FastJSON.JSONParameters param = new FastJSON.JSONParameters();
param.EnableAnonymousTypes = true;
string reqJson = FastJSON.JSON.ToJSON(reqAllDaKaJiLu,param);
05-11 15:12