using System; using System.Text; using System.Collections.Generic; using System.Reflection; using System.Linq; using ln.types.btree; using System.Security.Cryptography; namespace ln.json { public class JSONObject : JSONValue { public IEnumerable Keys => values.Keys; public override IEnumerable Children => values.Values; public override bool HasChildren => true; BTree values = new BTree(); public JSONObject() :base(JSONValueType.OBJECT){} public override JSONValue this[string property] { get => values[property]; set => values[property] = value; } public JSONObject Add(string propertyName,JSONValue value) { values[propertyName] = value; return this; } public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append('{'); IEnumerator kenum = values.Keys.GetEnumerator(); if (kenum.MoveNext()) do { sb.Append('"'); sb.Append(kenum.Current); sb.Append('"'); sb.Append(':'); sb.Append(values[kenum.Current].ToString()); if (!kenum.MoveNext()) break; sb.Append(','); } while (true); sb.Append('}'); return sb.ToString(); } } }