using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Neo.LegitimateLicences.Desktop.Helpers { public class JsonHelper { #region GetValidString public static string GetValidString(JValue obj) { return obj.ToString(); //if (obj.Value != null) //{ // return obj.ToString(); //} //else //{ // return "-"; //} } #endregion #region GetValidLong public static long? GetValidLong(JValue obj) { if (obj.Value != null) { return Convert.ToInt64(obj.ToString()); } else { return null; } } #endregion #region GetValidInt public static int? GetValidInt(JValue obj) { if (obj.Value != null) { return Convert.ToInt32(obj.ToString()); } else { return null; } } #endregion #region GetValidShort public static short? GetValidShort(JValue obj) { if (obj.Value != null) { return Convert.ToInt16(obj.ToString()); } else { return null; } } #endregion #region GetValidDate public static DateTime? GetValidDate(JValue obj) { if (obj.Value != null) { return Convert.ToDateTime(obj.ToString()); } else { return null; } } #endregion } }