public override JSONNode this[string aKey] { get { return(new JSONLazyCreator(this)); } set { if (value == null) { value = JSONNull.CreateOrGet(); } m_List.Add(value); } }
public override JSONNode this[string aKey] { get { return(_dict.TryGetValue(aKey ?? string.Empty, out var value) ? value : new JSONLazyCreator(this, aKey)); } set { _dict[aKey] = value ?? JSONNull.CreateOrGet(); } }
public static JSONNode DeserializeBinary(System.IO.BinaryReader aReader) { JSONNodeType type = (JSONNodeType)aReader.ReadByte(); switch (type) { case JSONNodeType.Array: { int count = aReader.ReadInt32(); JSONArray tmp = new JSONArray(); for (int i = 0; i < count; i++) { tmp.Add(DeserializeBinary(aReader)); } return(tmp); } case JSONNodeType.Object: { int count = aReader.ReadInt32(); JSONObject tmp = new JSONObject(); for (int i = 0; i < count; i++) { string key = aReader.ReadString(); var val = DeserializeBinary(aReader); tmp.Add(key, val); } return(tmp); } case JSONNodeType.String: { return(new JSONString(aReader.ReadString())); } case JSONNodeType.Number: { return(new JSONNumber(aReader.ReadDouble())); } case JSONNodeType.Boolean: { return(new JSONBool(aReader.ReadBoolean())); } case JSONNodeType.NullValue: { return(JSONNull.CreateOrGet()); } default: { throw new Exception("Error deserializing JSON. Unknown tag: " + type); } } }
public override JSONNode this[string aKey] { get { return(new global::a(this)); } set { if (value == null) { value = JSONNull.CreateOrGet(); } b.Add(value); } }
public static JSONNode DeserializeBinary(BinaryReader aReader) { JSONNodeType jSONNodeType = (JSONNodeType)aReader.ReadByte(); switch (jSONNodeType) { case JSONNodeType.Array: { int num2 = aReader.ReadInt32(); JSONArray jSONArray = new JSONArray(); for (int j = 0; j < num2; j++) { jSONArray.Add(DeserializeBinary(aReader)); } return(jSONArray); } case JSONNodeType.Object: { int num = aReader.ReadInt32(); JSONObject jSONObject = new JSONObject(); for (int i = 0; i < num; i++) { string aKey = aReader.ReadString(); JSONNode aItem = DeserializeBinary(aReader); jSONObject.Add(aKey, aItem); } return(jSONObject); } case JSONNodeType.String: return(new JSONString(aReader.ReadString())); case JSONNodeType.Number: return(new JSONNumber(aReader.ReadDouble())); case JSONNodeType.Boolean: return(new JSONBool(aReader.ReadBoolean())); case JSONNodeType.NullValue: return(JSONNull.CreateOrGet()); default: throw new Exception("Error deserializing JSON. Unknown tag: " + jSONNodeType); } }
private static JSONNode ParseElement(string token, bool quoted) { if (quoted) { return(token); } string tmp = token.ToLower(); if (tmp == "false" || tmp == "true") { return(tmp == "true"); } if (tmp == "null") { return(JSONNull.CreateOrGet()); } return(double.TryParse(token, NumberStyles.Float, CultureInfo.InvariantCulture, out double val) ? (JSONNode)val : (JSONNode)token); }
public override JSONNode this[int aIndex] { get { if (aIndex < 0 || aIndex >= m_Dict.Count) { return(null); } return(m_Dict.ElementAt(aIndex).Value); } set { if (value == null) { value = JSONNull.CreateOrGet(); } if (aIndex < 0 || aIndex >= m_Dict.Count) { return; } string key = m_Dict.ElementAt(aIndex).Key; m_Dict[key] = value; } }
public override void Add(string aKey, JSONNode aItem) { if (aItem == null) { aItem = JSONNull.CreateOrGet(); } if (!string.IsNullOrEmpty(aKey)) { if (m_Dict.ContainsKey(aKey)) { m_Dict[aKey] = aItem; } else { m_Dict.Add(aKey, aItem); } } else { m_Dict.Add(Guid.NewGuid().ToString(), aItem); } }
public override JSONNode this[int aIndex] { get { if (aIndex < 0 || aIndex >= m_List.Count) { return(new JSONLazyCreator(this)); } return(m_List[aIndex]); } set { if (value == null) { value = JSONNull.CreateOrGet(); } if (aIndex < 0 || aIndex >= m_List.Count) { m_List.Add(value); } else { m_List[aIndex] = value; } } }
public override JSONNode this[int aIndex] { get { if (aIndex < 0 || aIndex >= d.Count) { return(null); } return(d.ElementAt(aIndex).Value); } set { if (value == null) { value = JSONNull.CreateOrGet(); } if (aIndex >= 0 && aIndex < d.Count) { string key = d.ElementAt(aIndex).Key; d[key] = value; } } }
private static JSONNode ParseElement(string token, bool quoted) { if (quoted) { return(token); } string tmp = token.ToLower(); if (tmp == "false" || tmp == "true") { return(tmp == "true"); } if (tmp == "null") { return(JSONNull.CreateOrGet()); } //! veg Patched start. Boolean isLong = (longAsString && long.TryParse(token, out long lval)); if (double.TryParse(token, NumberStyles.Float, CultureInfo.InvariantCulture, out double rval)) { if (isLong && !rval.ToString("F0").Equals(token)) { return(token); } else { return(rval); } } else { return(token); } //! veg Patched end. }
public override JSONNode this[string aKey] { get { if (m_Dict.ContainsKey(aKey)) { return(m_Dict[aKey]); } else { return(new JSONLazyCreator(this, aKey)); } } set { if (value == null) { value = JSONNull.CreateOrGet(); } if (m_Dict.ContainsKey(aKey)) { m_Dict[aKey] = value; } else { m_Dict.Add(aKey, value); } } }
public override void Add(string aKey, JSONNode aItem) { _dict[aKey ?? string.Empty] = aItem ?? JSONNull.CreateOrGet(); }