12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using System.Collections.Specialized;
- using System.Globalization;
- using System.IO;
- using UnityEngine;
- namespace LitJson
- {
- public class JsonData : IEquatable<JsonData>, IList, IOrderedDictionary, IEnumerable, ICollection, IDictionary, IJsonWrapper
- {
- public JsonData()
- {
- }
- public JsonData(bool boolean)
- {
- this.type = JsonType.Boolean;
- this.inst_boolean = boolean;
- }
- public JsonData(double number)
- {
- this.type = JsonType.Double;
- this.inst_double = number;
- }
- public JsonData(int number)
- {
- this.type = JsonType.Int;
- this.inst_int = number;
- }
- public JsonData(long number)
- {
- this.type = JsonType.Long;
- this.inst_long = number;
- }
- public JsonData(object obj)
- {
- if (obj is bool)
- {
- this.type = JsonType.Boolean;
- this.inst_boolean = (bool)obj;
- return;
- }
- if (obj is double)
- {
- this.type = JsonType.Double;
- this.inst_double = (double)obj;
- return;
- }
- if (obj is int)
- {
- this.type = JsonType.Int;
- this.inst_int = (int)obj;
- return;
- }
- if (obj is long)
- {
- this.type = JsonType.Long;
- this.inst_long = (long)obj;
- return;
- }
- if (obj is string)
- {
- this.type = JsonType.String;
- this.inst_string = (string)obj;
- return;
- }
- throw new ArgumentException("Unable to wrap the given object with JsonData");
- }
- public JsonData(string str)
- {
- this.type = JsonType.String;
- this.inst_string = str;
- }
- public JsonData(Vector2 vector2)
- {
- this.SetJsonType(JsonType.Object);
- this.inst_object["x"] = (double)vector2.x;
- this.inst_object["y"] = (double)vector2.y;
- }
- public JsonData(Vector3 vector3)
- {
- this.SetJsonType(JsonType.Object);
- this.inst_object["x"] = (double)vector3.x;
- this.inst_object["y"] = (double)vector3.y;
- this.inst_object["z"] = (double)vector3.z;
- }
- public JsonData(Vector4 vector4)
- {
- this.SetJsonType(JsonType.Object);
- this.inst_object["x"] = (double)vector4.x;
- this.inst_object["y"] = (double)vector4.y;
- this.inst_object["z"] = (double)vector4.z;
- this.inst_object["w"] = (double)vector4.w;
- }
- public JsonData(Quaternion quaternion)
- {
- this.SetJsonType(JsonType.Object);
- this.inst_object["x"] = (double)quaternion.x;
- this.inst_object["y"] = (double)quaternion.y;
- this.inst_object["z"] = (double)quaternion.z;
- this.inst_object["w"] = (double)quaternion.w;
- }
- public JsonData(Rect rect)
- {
- this.SetJsonType(JsonType.Object);
- this.inst_object["x"] = (double)rect.x;
- this.inst_object["y"] = (double)rect.y;
- this.inst_object["w"] = (double)rect.width;
- this.inst_object["h"] = (double)rect.height;
- }
- public int Count
- {
- get
- {
- return this.EnsureCollection().Count;
- }
- }
- public bool IsArray
- {
- get
- {
- return this.type == JsonType.Array;
- }
- }
- public bool IsBoolean
- {
- get
- {
- return this.type == JsonType.Boolean;
- }
- }
- public bool IsDouble
- {
- get
- {
- return this.type == JsonType.Double;
- }
- }
- public bool IsInt
- {
- get
- {
- return this.type == JsonType.Int;
- }
- }
- public bool IsLong
- {
- get
- {
- return this.type == JsonType.Long;
- }
- }
- public bool IsObject
- {
- get
- {
- return this.type == JsonType.Object;
- }
- }
- public bool IsString
- {
- get
- {
- return this.type == JsonType.String;
- }
- }
- public ICollection<string> Keys
- {
- get
- {
- this.EnsureDictionary();
- return this.inst_object.Keys;
- }
- }
- int ICollection.Count
- {
- get
- {
- return this.Count;
- }
- }
- bool ICollection.IsSynchronized
- {
- get
- {
- return this.EnsureCollection().IsSynchronized;
- }
- }
- object ICollection.SyncRoot
- {
- get
- {
- return this.EnsureCollection().SyncRoot;
- }
- }
- bool IDictionary.IsFixedSize
- {
- get
- {
- return this.EnsureDictionary().IsFixedSize;
- }
- }
- bool IDictionary.IsReadOnly
- {
- get
- {
- return this.EnsureDictionary().IsReadOnly;
- }
- }
- ICollection IDictionary.Keys
- {
- get
- {
- this.EnsureDictionary();
- IList<string> list = new List<string>();
- foreach (KeyValuePair<string, JsonData> keyValuePair in this.object_list)
- {
- list.Add(keyValuePair.Key);
- }
- return (ICollection)list;
- }
- }
- ICollection IDictionary.Values
- {
- get
- {
- this.EnsureDictionary();
- IList<JsonData> list = new List<JsonData>();
- foreach (KeyValuePair<string, JsonData> keyValuePair in this.object_list)
- {
- list.Add(keyValuePair.Value);
- }
- return (ICollection)list;
- }
- }
- bool IJsonWrapper.IsArray
- {
- get
- {
- return this.IsArray;
- }
- }
- bool IJsonWrapper.IsBoolean
- {
- get
- {
- return this.IsBoolean;
- }
- }
- bool IJsonWrapper.IsDouble
- {
- get
- {
- return this.IsDouble;
- }
- }
- bool IJsonWrapper.IsInt
- {
- get
- {
- return this.IsInt;
- }
- }
- bool IJsonWrapper.IsLong
- {
- get
- {
- return this.IsLong;
- }
- }
- bool IJsonWrapper.IsObject
- {
- get
- {
- return this.IsObject;
- }
- }
- bool IJsonWrapper.IsString
- {
- get
- {
- return this.IsString;
- }
- }
- bool IList.IsFixedSize
- {
- get
- {
- return this.EnsureList().IsFixedSize;
- }
- }
- bool IList.IsReadOnly
- {
- get
- {
- return this.EnsureList().IsReadOnly;
- }
- }
- object IDictionary.this[object key]
- {
- get
- {
- return this.EnsureDictionary()[key];
- }
- set
- {
- if (!(key is string))
- {
- throw new ArgumentException("The key has to be a string");
- }
- JsonData value2 = this.ToJsonData(value);
- this[(string)key] = value2;
- }
- }
- object IOrderedDictionary.this[int idx]
- {
- get
- {
- this.EnsureDictionary();
- return this.object_list[idx].Value;
- }
- set
- {
- this.EnsureDictionary();
- JsonData value2 = this.ToJsonData(value);
- KeyValuePair<string, JsonData> keyValuePair = this.object_list[idx];
- this.inst_object[keyValuePair.Key] = value2;
- KeyValuePair<string, JsonData> value3 = new KeyValuePair<string, JsonData>(keyValuePair.Key, value2);
- this.object_list[idx] = value3;
- }
- }
- object IList.this[int index]
- {
- get
- {
- return this.EnsureList()[index];
- }
- set
- {
- this.EnsureList();
- JsonData value2 = this.ToJsonData(value);
- this[index] = value2;
- }
- }
- public JsonData this[string prop_name]
- {
- get
- {
- this.EnsureDictionary();
- return this.inst_object[prop_name];
- }
- set
- {
- this.EnsureDictionary();
- KeyValuePair<string, JsonData> keyValuePair = new KeyValuePair<string, JsonData>(prop_name, value);
- if (this.inst_object.ContainsKey(prop_name))
- {
- for (int i = 0; i < this.object_list.Count; i++)
- {
- if (this.object_list[i].Key == prop_name)
- {
- this.object_list[i] = keyValuePair;
- break;
- }
- }
- }
- else
- {
- this.object_list.Add(keyValuePair);
- }
- this.inst_object[prop_name] = value;
- this.json = null;
- }
- }
- public JsonData this[int index]
- {
- get
- {
- this.EnsureCollection();
- if (this.type == JsonType.Array)
- {
- return this.inst_array[index];
- }
- return this.object_list[index].Value;
- }
- set
- {
- this.EnsureCollection();
- if (this.type == JsonType.Array)
- {
- this.inst_array[index] = value;
- }
- else
- {
- KeyValuePair<string, JsonData> keyValuePair = this.object_list[index];
- KeyValuePair<string, JsonData> value2 = new KeyValuePair<string, JsonData>(keyValuePair.Key, value);
- this.object_list[index] = value2;
- this.inst_object[keyValuePair.Key] = value;
- }
- this.json = null;
- }
- }
- public static implicit operator JsonData(bool data)
- {
- return new JsonData(data);
- }
- public static implicit operator JsonData(double data)
- {
- return new JsonData(data);
- }
- public static implicit operator JsonData(int data)
- {
- return new JsonData(data);
- }
- public static implicit operator JsonData(long data)
- {
- return new JsonData(data);
- }
- public static implicit operator JsonData(string data)
- {
- return new JsonData(data);
- }
- public static implicit operator JsonData(Vector2 data)
- {
- return new JsonData(data);
- }
- public static implicit operator JsonData(Vector3 data)
- {
- return new JsonData(data);
- }
- public static implicit operator JsonData(Vector4 data)
- {
- return new JsonData(data);
- }
- public static implicit operator JsonData(Quaternion data)
- {
- return new JsonData(data);
- }
- public static implicit operator JsonData(Rect data)
- {
- return new JsonData(data);
- }
- public static explicit operator bool(JsonData data)
- {
- if (data.type != JsonType.Boolean)
- {
- throw new InvalidCastException("Instance of JsonData doesn't hold a double");
- }
- return data.inst_boolean;
- }
- public static explicit operator double(JsonData data)
- {
- if (data.type != JsonType.Double)
- {
- throw new InvalidCastException("Instance of JsonData doesn't hold a double");
- }
- return data.inst_double;
- }
- public static explicit operator int(JsonData data)
- {
- if (data.type != JsonType.Int)
- {
- throw new InvalidCastException("Instance of JsonData doesn't hold an int");
- }
- return data.inst_int;
- }
- public static explicit operator long(JsonData data)
- {
- if (data.type != JsonType.Long)
- {
- throw new InvalidCastException("Instance of JsonData doesn't hold an int");
- }
- return data.inst_long;
- }
- public static explicit operator string(JsonData data)
- {
- if (data.type != JsonType.String)
- {
- throw new InvalidCastException("Instance of JsonData doesn't hold a string");
- }
- return data.inst_string;
- }
- void ICollection.CopyTo(Array array, int index)
- {
- this.EnsureCollection().CopyTo(array, index);
- }
- void IDictionary.Add(object key, object value)
- {
- JsonData value2 = this.ToJsonData(value);
- this.EnsureDictionary().Add(key, value2);
- KeyValuePair<string, JsonData> item = new KeyValuePair<string, JsonData>((string)key, value2);
- this.object_list.Add(item);
- this.json = null;
- }
- void IDictionary.Clear()
- {
- this.EnsureDictionary().Clear();
- this.object_list.Clear();
- this.json = null;
- }
- bool IDictionary.Contains(object key)
- {
- return this.EnsureDictionary().Contains(key);
- }
- IDictionaryEnumerator IDictionary.GetEnumerator()
- {
- return ((IOrderedDictionary)this).GetEnumerator();
- }
- void IDictionary.Remove(object key)
- {
- this.EnsureDictionary().Remove(key);
- for (int i = 0; i < this.object_list.Count; i++)
- {
- if (this.object_list[i].Key == (string)key)
- {
- this.object_list.RemoveAt(i);
- break;
- }
- }
- this.json = null;
- }
- IEnumerator IEnumerable.GetEnumerator()
- {
- return this.EnsureCollection().GetEnumerator();
- }
- bool IJsonWrapper.GetBoolean()
- {
- if (this.type != JsonType.Boolean)
- {
- throw new InvalidOperationException("JsonData instance doesn't hold a boolean");
- }
- return this.inst_boolean;
- }
- double IJsonWrapper.GetDouble()
- {
- if (this.type != JsonType.Double)
- {
- throw new InvalidOperationException("JsonData instance doesn't hold a double");
- }
- return this.inst_double;
- }
- int IJsonWrapper.GetInt()
- {
- if (this.type != JsonType.Int)
- {
- throw new InvalidOperationException("JsonData instance doesn't hold an int");
- }
- return this.inst_int;
- }
- long IJsonWrapper.GetLong()
- {
- if (this.type != JsonType.Long)
- {
- throw new InvalidOperationException("JsonData instance doesn't hold a long");
- }
- return this.inst_long;
- }
- string IJsonWrapper.GetString()
- {
- if (this.type != JsonType.String)
- {
- throw new InvalidOperationException("JsonData instance doesn't hold a string");
- }
- return this.inst_string;
- }
- void IJsonWrapper.SetBoolean(bool val)
- {
- this.type = JsonType.Boolean;
- this.inst_boolean = val;
- this.json = null;
- }
- void IJsonWrapper.SetDouble(double val)
- {
- this.type = JsonType.Double;
- this.inst_double = val;
- this.json = null;
- }
- void IJsonWrapper.SetInt(int val)
- {
- this.type = JsonType.Int;
- this.inst_int = val;
- this.json = null;
- }
- void IJsonWrapper.SetLong(long val)
- {
- this.type = JsonType.Long;
- this.inst_long = val;
- this.json = null;
- }
- void IJsonWrapper.SetString(string val)
- {
- this.type = JsonType.String;
- this.inst_string = val;
- this.json = null;
- }
- string IJsonWrapper.ToJson()
- {
- return this.ToJson();
- }
- void IJsonWrapper.ToJson(JsonWriter writer)
- {
- this.ToJson(writer);
- }
- int IList.Add(object value)
- {
- return this.Add(value);
- }
- void IList.Clear()
- {
- this.EnsureList().Clear();
- this.json = null;
- }
- bool IList.Contains(object value)
- {
- return this.EnsureList().Contains(value);
- }
- int IList.IndexOf(object value)
- {
- return this.EnsureList().IndexOf(value);
- }
- void IList.Insert(int index, object value)
- {
- this.EnsureList().Insert(index, value);
- this.json = null;
- }
- void IList.Remove(object value)
- {
- this.EnsureList().Remove(value);
- this.json = null;
- }
- void IList.RemoveAt(int index)
- {
- this.EnsureList().RemoveAt(index);
- this.json = null;
- }
- IDictionaryEnumerator IOrderedDictionary.GetEnumerator()
- {
- this.EnsureDictionary();
- return new OrderedDictionaryEnumerator(this.object_list.GetEnumerator());
- }
- void IOrderedDictionary.Insert(int idx, object key, object value)
- {
- string text = (string)key;
- JsonData value2 = this.ToJsonData(value);
- this[text] = value2;
- KeyValuePair<string, JsonData> item = new KeyValuePair<string, JsonData>(text, value2);
- this.object_list.Insert(idx, item);
- }
- void IOrderedDictionary.RemoveAt(int idx)
- {
- this.EnsureDictionary();
- this.inst_object.Remove(this.object_list[idx].Key);
- this.object_list.RemoveAt(idx);
- }
- private ICollection EnsureCollection()
- {
- if (this.type == JsonType.Array)
- {
- return (ICollection)this.inst_array;
- }
- if (this.type == JsonType.Object)
- {
- return (ICollection)this.inst_object;
- }
- throw new InvalidOperationException("The JsonData instance has to be initialized first");
- }
- private IDictionary EnsureDictionary()
- {
- if (this.type == JsonType.Object)
- {
- return (IDictionary)this.inst_object;
- }
- if (this.type != JsonType.None)
- {
- throw new InvalidOperationException("Instance of JsonData is not a dictionary");
- }
- this.type = JsonType.Object;
- this.inst_object = new Dictionary<string, JsonData>();
- this.object_list = new List<KeyValuePair<string, JsonData>>();
- return (IDictionary)this.inst_object;
- }
- private IList EnsureList()
- {
- if (this.type == JsonType.Array)
- {
- return (IList)this.inst_array;
- }
- if (this.type != JsonType.None)
- {
- throw new InvalidOperationException("Instance of JsonData is not a list");
- }
- this.type = JsonType.Array;
- this.inst_array = new List<JsonData>();
- return (IList)this.inst_array;
- }
- private JsonData ToJsonData(object obj)
- {
- if (obj == null)
- {
- return null;
- }
- if (obj is JsonData)
- {
- return (JsonData)obj;
- }
- return new JsonData(obj);
- }
- private static void WriteJson(IJsonWrapper obj, JsonWriter writer)
- {
- if (obj == null)
- {
- writer.Write(null);
- return;
- }
- if (obj.IsString)
- {
- writer.Write(obj.GetString());
- return;
- }
- if (obj.IsBoolean)
- {
- writer.Write(obj.GetBoolean());
- return;
- }
- if (obj.IsDouble)
- {
- writer.Write(obj.GetDouble());
- return;
- }
- if (obj.IsInt)
- {
- writer.Write(obj.GetInt());
- return;
- }
- if (obj.IsLong)
- {
- writer.Write(obj.GetLong());
- return;
- }
- if (obj.IsArray)
- {
- writer.WriteArrayStart();
- IEnumerator enumerator = obj.GetEnumerator();
- try
- {
- while (enumerator.MoveNext())
- {
- object obj2 = enumerator.Current;
- JsonData.WriteJson((JsonData)obj2, writer);
- }
- }
- finally
- {
- IDisposable disposable;
- if ((disposable = (enumerator as IDisposable)) != null)
- {
- disposable.Dispose();
- }
- }
- writer.WriteArrayEnd();
- return;
- }
- if (obj.IsObject)
- {
- writer.WriteObjectStart();
- IDictionaryEnumerator enumerator2 = obj.GetEnumerator();
- try
- {
- while (enumerator2.MoveNext())
- {
- object obj3 = enumerator2.Current;
- DictionaryEntry dictionaryEntry = (DictionaryEntry)obj3;
- writer.WritePropertyName((string)dictionaryEntry.Key);
- JsonData.WriteJson((JsonData)dictionaryEntry.Value, writer);
- }
- }
- finally
- {
- IDisposable disposable2;
- if ((disposable2 = (enumerator2 as IDisposable)) != null)
- {
- disposable2.Dispose();
- }
- }
- writer.WriteObjectEnd();
- return;
- }
- }
- private object Get(object key, object defaultValue)
- {
- return (!this.Contains(key)) ? defaultValue : this.EnsureDictionary()[key];
- }
- private object Get(object key)
- {
- return this.EnsureDictionary()[key];
- }
- public int Add(object value)
- {
- JsonData value2 = this.ToJsonData(value);
- this.json = null;
- return this.EnsureList().Add(value2);
- }
- public void Clear()
- {
- if (this.IsObject)
- {
- ((IDictionary)this).Clear();
- return;
- }
- if (this.IsArray)
- {
- ((IList)this).Clear();
- return;
- }
- }
- public bool Equals(JsonData x)
- {
- if (x == null)
- {
- return false;
- }
- if (x.type != this.type)
- {
- return false;
- }
- switch (this.type)
- {
- case JsonType.None:
- return true;
- case JsonType.Object:
- return this.inst_object.Equals(x.inst_object);
- case JsonType.Array:
- return this.inst_array.Equals(x.inst_array);
- case JsonType.String:
- return this.inst_string.Equals(x.inst_string);
- case JsonType.Int:
- return this.inst_int.Equals(x.inst_int);
- case JsonType.Long:
- return this.inst_long.Equals(x.inst_long);
- case JsonType.Double:
- return this.inst_double.Equals(x.inst_double);
- case JsonType.Boolean:
- return this.inst_boolean.Equals(x.inst_boolean);
- default:
- return false;
- }
- }
- public JsonType GetJsonType()
- {
- return this.type;
- }
- public void SetJsonType(JsonType type)
- {
- if (this.type == type)
- {
- return;
- }
- switch (type)
- {
- case JsonType.Object:
- this.inst_object = new Dictionary<string, JsonData>();
- this.object_list = new List<KeyValuePair<string, JsonData>>();
- break;
- case JsonType.Array:
- this.inst_array = new List<JsonData>();
- break;
- case JsonType.String:
- this.inst_string = null;
- break;
- case JsonType.Int:
- this.inst_int = 0;
- break;
- case JsonType.Long:
- this.inst_long = 0L;
- break;
- case JsonType.Double:
- this.inst_double = 0.0;
- break;
- case JsonType.Boolean:
- this.inst_boolean = false;
- break;
- }
- this.type = type;
- }
- public string ToJson()
- {
- if (this.json != null)
- {
- return this.json;
- }
- StringWriter stringWriter = new StringWriter();
- JsonData.WriteJson(this, new JsonWriter(stringWriter)
- {
- Validate = false
- });
- this.json = stringWriter.ToString();
- return this.json;
- }
- public void ToJson(JsonWriter writer)
- {
- bool validate = writer.Validate;
- writer.Validate = false;
- JsonData.WriteJson(this, writer);
- writer.Validate = validate;
- }
- public override string ToString()
- {
- switch (this.type)
- {
- case JsonType.Object:
- return "JsonData object";
- case JsonType.Array:
- return "JsonData array";
- case JsonType.String:
- return this.inst_string;
- case JsonType.Int:
- return this.inst_int.ToString();
- case JsonType.Long:
- return this.inst_long.ToString();
- case JsonType.Double:
- return this.inst_double.ToString(CultureInfo.InvariantCulture);
- case JsonType.Boolean:
- return this.inst_boolean.ToString();
- default:
- return "Uninitialized JsonData";
- }
- }
- public bool Contains(object key)
- {
- return this.EnsureDictionary().Contains(key);
- }
- public T Get<T>(int index, T defaultValue = default(T))
- {
- if (!this.IsArray)
- {
- return defaultValue;
- }
- T result;
- try
- {
- result = (T)((object)Convert.ChangeType(this[index].ToString(), typeof(T), CultureInfo.InvariantCulture));
- }
- catch (Exception message)
- {
- UnityEngine.Debug.LogError(message);
- result = defaultValue;
- }
- return result;
- }
- public T Get<T>(string key, T defaultValue = default(T))
- {
- if (!this.Contains(key))
- {
- return defaultValue;
- }
- T result;
- try
- {
- result = (T)((object)Convert.ChangeType(this.Get(key).ToString(), typeof(T), CultureInfo.InvariantCulture));
- }
- catch (Exception message)
- {
- UnityEngine.Debug.LogError(message);
- result = defaultValue;
- }
- return result;
- }
- public T[] ConventToArray<T>()
- {
- if (this.IsArray)
- {
- T[] array = new T[this.Count];
- for (int i = 0; i < this.Count; i++)
- {
- array[i] = (T)((object)Convert.ChangeType(this[i].ToString(), typeof(T), CultureInfo.InvariantCulture));
- }
- return array;
- }
- return null;
- }
- public void Remove(object key)
- {
- this.EnsureDictionary().Remove(key);
- for (int i = 0; i < this.object_list.Count; i++)
- {
- if (this.object_list[i].Key == (string)key)
- {
- this.object_list.RemoveAt(i);
- break;
- }
- }
- this.json = null;
- }
- private IList<JsonData> inst_array;
- private bool inst_boolean;
- private double inst_double;
- private int inst_int;
- private long inst_long;
- private IDictionary<string, JsonData> inst_object;
- private string inst_string;
- private string json;
- private JsonType type;
- private IList<KeyValuePair<string, JsonData>> object_list;
- }
- }
|