using System; using System.Collections.Generic; using System.Linq; using System.Text; using Newtonsoft.Json; using System.IO; namespace Bowin.Common.JSON { public static class ConvertJsonToObject { public static T ToObject(this string json) { return JsonConvert.DeserializeObject(json, new JsonSerializerSettings { DateTimeZoneHandling = DateTimeZoneHandling.Local, NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore }); } public static string ToJson(this object obj) { return JsonConvert.SerializeObject(obj, new JsonSerializerSettings { DateTimeZoneHandling = DateTimeZoneHandling.Local, NullValueHandling = NullValueHandling.Ignore, MissingMemberHandling = MissingMemberHandling.Ignore }); } public static T Map(this object obj) where T : class { return obj.ToJson().ToObject(); } } }