public static JSONNode Deserialize(System.IO.BinaryReader aReader)
        {
            JSONBinaryTag type = (JSONBinaryTag)aReader.ReadByte();

            switch (type)
            {
            case JSONBinaryTag.Array:
            {
                int       count = aReader.ReadInt32();
                JSONArray tmp   = new JSONArray();
                for (int i = 0; i < count; i++)
                {
                    tmp.Add(Deserialize(aReader));
                }
                return(tmp);
            }

            case JSONBinaryTag.Class:
            {
                int       count = aReader.ReadInt32();
                JSONClass tmp   = new JSONClass();
                for (int i = 0; i < count; i++)
                {
                    string key = aReader.ReadString();
                    var    val = Deserialize(aReader);
                    tmp.Add(key, val);
                }
                return(tmp);
            }

            case JSONBinaryTag.Value:
            {
                return(new JSONData(aReader.ReadString()));
            }

            case JSONBinaryTag.IntValue:
            {
                return(new JSONData(aReader.ReadInt32()));
            }

            case JSONBinaryTag.DoubleValue:
            {
                return(new JSONData(aReader.ReadDouble()));
            }

            case JSONBinaryTag.BoolValue:
            {
                return(new JSONData(aReader.ReadBoolean()));
            }

            case JSONBinaryTag.FloatValue:
            {
                return(new JSONData(aReader.ReadSingle()));
            }

            default:
            {
                throw new Exception("Error deserializing JSON. Unknown tag: " + type);
            }
            }
        }
		public override void Add (JSONNode aItem)
		{
			var tmp = new JSONArray();
			tmp.Add(aItem);
			Set(tmp);
		}
		public static JSONNode Deserialize(System.IO.BinaryReader aReader)
		{
			JSONBinaryTag type = (JSONBinaryTag)aReader.ReadByte();
			switch(type)
			{
			case JSONBinaryTag.Array:
			{
				int count = aReader.ReadInt32();
				JSONArray tmp = new JSONArray();
				for(int i = 0; i < count; i++)
					tmp.Add(Deserialize(aReader));
				return tmp;
			}
			case JSONBinaryTag.Class:
			{
				int count = aReader.ReadInt32();                
				JSONClass tmp = new JSONClass();
				for(int i = 0; i < count; i++)
				{
					string key = aReader.ReadString();
					var val = Deserialize(aReader);
					tmp.Add(key, val);
				}
				return tmp;
			}
			case JSONBinaryTag.Value:
			{
				return new JSONData(aReader.ReadString());
			}
			case JSONBinaryTag.IntValue:
			{
				return new JSONData(aReader.ReadInt32());
			}
			case JSONBinaryTag.DoubleValue:
			{
				return new JSONData(aReader.ReadDouble());
			}
			case JSONBinaryTag.BoolValue:
			{
				return new JSONData(aReader.ReadBoolean());
			}
			case JSONBinaryTag.FloatValue:
			{
				return new JSONData(aReader.ReadSingle());
			}
				
			default:
			{
				throw new Exception("Error deserializing JSON. Unknown tag: " + type);
			}
			}
		}
		public override JSONNode this[int aIndex]
		{
			get
			{
				return new JSONLazyCreator(this);
			}
			set
			{
				var tmp = new JSONArray();
				tmp.Add(value);
				Set(tmp);
			}
		}
		public static JSONClass TestClass() {
			JSONClass container = new JSONClass();
			JSONClass subContainer = new JSONClass();
			JSONArray subArray     = new JSONArray();
			
			subContainer["key1"         ]          = "value1";
			
			subArray    [0              ].AsInt    = 0;
			subArray    [1              ].AsInt    = 1;
			subArray    [2              ]          = "2";
			subArray    [3              ]          = "3";
			
			container   ["boolean true" ].AsBool   = true;
			container   ["boolean false"].AsBool   = false;
			container   ["int 0"        ].AsInt    = 0;
			container   ["int 1"        ].AsInt    = 1;
			container   ["float 0"      ].AsFloat  = 0.0f;
			container   ["float 1"      ].AsFloat  = 1.0f;
			container   ["double 0"     ].AsDouble = 0.0;
			container   ["double 1"     ].AsDouble = 1.0;
			container   ["string hello" ]          = "hello";
			container   ["string 0"     ]          = "0";
			container   ["class"        ]          = subContainer;
			container   ["array"        ]          = subArray;
			
			return container;
		}