-
Notifications
You must be signed in to change notification settings - Fork 111
Home
陈鑫伟 edited this page May 24, 2019
·
4 revisions
public class Demo
{
public int Id { get; set; }
public string Name { get; set; }
public static void Main()
{
var json = JsonFormatter.SerializeObject(new { Id = 1, Name = "Dogwei" });
var dic = JsonFormatter.DeserializeObject<Dictionary<string, object>>(json);
var obj = JsonFormatter.DeserializeObject<Demo>(json);;
}
}
// 实例方式用法。
// 需用启用多个功能请用 按位或 |。
var jsonFormatter = new JsonFormatter(
JsonFormatterOptions.Indented |
JsonFormatterOptions.IgnoreNull);
// 静态方法用法。
JsonFormatter.SerializeObject(obj, JsonFormatterOptions.Indented);
JsonFormatter.DeserializeObject<object>(json, JsonFormatterOptions.Indented);