public static T FromJsonWithZip <T>(byte[] content, bool zip = false) { if (zip) { var data = Zip7Helper.DecompressLZMA(content); return(JsonUtility.FromJson <T>(sUTF8NBOM.GetString(data))); } return(JsonUtility.FromJson <T>(sUTF8NBOM.GetString(content))); }
public static T From <T>(string content, bool zip = false) { T ret = default(T); try { if (zip) { var data = Zip7Helper.DecompressLZMA(sUTF8NBOM.GetBytes(content)); content = sUTF8NBOM.GetString(data); } ret = UnityEngine.JsonUtility.FromJson <T>(content); } catch (Exception exc) { UnityEngine.Debug.LogWarning(content + exc.Message); } return(ret); }
public static T LoadJsonObject <T>(string path, bool zip = false) { try { if (zip) { var raw = System.IO.File.ReadAllBytes(path); var data = Zip7Helper.DecompressLZMA(raw); return(JsonUtility.FromJson <T>(sUTF8NBOM.GetString(data))); } else { var content = System.IO.File.ReadAllText(path, sUTF8NBOM); return(JsonUtility.FromJson <T>(content)); } } catch (Exception exc) { } return(default(T)); }