| | |
| | | using Newtonsoft.Json; |
| | | using Newtonsoft.Json.Linq; |
| | | using System.IO; |
| | | |
| | | namespace HMI.Core.Util |
| | | { |
| | | public class JsonUtil |
| | | { |
| | | static readonly JsonSerializerSettings JsSetting = new JsonSerializerSettings() |
| | | { |
| | | NullValueHandling = NullValueHandling.Ignore |
| | | }; |
| | | public static T Deserialize<T>(string jsonStr) |
| | | { |
| | | return JsonConvert.DeserializeObject<T>(jsonStr); |
| | | } |
| | | |
| | | public static string Serialize(object obj) |
| | | { |
| | | return JsonConvert.SerializeObject(obj); |
| | | } |
| | | |
| | | public static string Stringfiy(object obj) |
| | | { |
| | | return JsonConvert.SerializeObject(obj, Formatting.Indented, JsSetting); |
| | | } |
| | | } |
| | | } |