using System; using System.IO; using System.Text; using System.Collections.Generic; namespace sharp.json { public abstract class JSON { List keys = new List(); List values = new List(); public JSON this[int n] { get { return values[n]; } set{ values[n] = value; } } public JSON this[string name] { get { return values[keys.IndexOf(name)]; } set{ if (keys.Contains(name)){ values[keys.IndexOf(name)] = value; } else { keys.Add(name); values.Add(value); } } } public string[] Keys { get { return this.keys.ToArray(); } } public JSON[] Values { get { return this.values.ToArray(); } } public void Add(JSON element){ this.values.Add(element); } public virtual bool isTrue(){ return this.JSONType == JSONTypes.True; } public int Count { get { return values.Count; } } public JSONTypes JSONType { get; private set; } protected JSON(JSONTypes type){ JSONType = type; } public abstract string prettyPrint(int d); public override abstract string ToString(); public static JSON parse(String jsonSource){ return new ByteParser(jsonSource).parse(); } } }