protected JList <T> GetList <T>(string key, bool reseteable = true, int capacity = 0, bool subscribeToChildren = true) where T : JNode { if (!initialized) { this[key] = new JList <T>(reseteable, capacity, subscribeToChildren); } return(this[key] as JList <T>); }
protected JList GetList(string key, bool reseteable = true, int capacity = 0, bool subscribeToChildren = true) { if (!initialized) { this[key] = new JList(reseteable, capacity, subscribeToChildren); } return(this[key].AsList()); }
public override JNode Clone() { var newList = new JList(reseteable, list.Count, subscribeToChildren); for (int i = 0; i < list.Count; ++i) { newList.Add(list[i].Clone()); } return(newList); }
private static JNode Process(JsonValue value) { JNode result; switch (value.JsonType) { case JsonType.Object: var jsonObject = value.Qo(); var dict = new JDict(false, jsonObject.Count, true); result = dict; foreach (var kvp in jsonObject) { dict.Add(kvp.Key, Process(kvp.Value)); } break; case JsonType.Array: var jsonArray = value.Qa(); var list = new JList(true, jsonArray.Count, true); result = list; foreach (var item in jsonArray) { list.Add(Process(item)); } break; case JsonType.Boolean: result = new JData <bool>(value.Qb(), default(bool)); break; case JsonType.Number: var valueType = value.ToValue().GetType(); if (valueType == typeof(int)) { result = new JData <int>(value.Qi(), default(int)); } else if (valueType == typeof(long)) { result = new JData <long>(value.Ql(), default(long)); } else if (valueType == typeof(float)) { result = new JData <float>((float)value.Qd(), default(float)); } else if (valueType == typeof(double)) { result = new JData <double>(value.Qd(), default(double)); } else { throw new Exception($"JsonValue of type Number contains an invalid type of: {valueType.GetFriendlyName()}."); } break; case JsonType.String: // TODO: Try to detect types and convert result = new JData <string>(value.Qs(), default(string)); break; case JsonType.Unknown: default: result = new JData <string>(value.Qstr(), default(string)); break; } return(result); }