void JsonSerializationTest() { var a = new TestClass { ID = 123, Type = EnumType.Option1, IgnoredString = "Ignored string data", Data = new List <StructType> () }; var b = new StructType { ID = 456, IgnoredInt = 789, StructString = "Struct string data", RenamedString = "Renamed string data" }; a.Data.Add(b); Debug.Log("Data before serialization: " + a); var json = JsonSerialization.SerializeStatic(a); Debug.Log("json: " + json); var c = JsonSerialization.DeserializeStatic <TestClass> (json); Debug.Log("Data after deserialization: " + c); }
static void LoadInfo() { try { _allDescs = JsonSerialization.DeserializeStatic <Dictionary <string, FolderIconDesc> > (ProjectPrefs.GetString(StorageKey, "{}")); if (_allDescs == null) { throw new Exception(); } } catch { _allDescs = new Dictionary <string, FolderIconDesc> (); } }
void Load() { try { _paths = JsonSerialization.DeserializeStatic <Dictionary <string, string> > (ProjectPrefs.GetString(ProjectPrefsKey, string.Empty)); if (_paths == null) { throw new Exception(); } } catch { _paths = new Dictionary <string, string> (); } }
void LoadData() { try { Debug.Log("tutorials: " + PlayerPrefs.GetString(TutorialKey)); _sceneMasks = JsonSerialization.DeserializeStatic <Dictionary <string, int> > (PlayerPrefs.GetString(TutorialKey)); } catch { // Debug.LogWarning (ex); _sceneMasks = null; } if (_sceneMasks == null) { _sceneMasks = new Dictionary <string, int> (); } }
static void LoadData() { if (_storeFile == null) { _storeFile = string.Format(StorePath, Application.dataPath); } if (_data == null) { try { _data = JsonSerialization.DeserializeStatic <Dictionary <string, string> > (File.ReadAllText(_storeFile)); if (_data == null) { throw new UnityException(); } } catch { _data = new Dictionary <string, string> (); } } }