コード例 #1
0
ファイル: SimpleJSON.cs プロジェクト: SimonBellV/v0.93
        public override void Add(string aKey, SimpleJSONNode aItem)
        {
            var tmp = new SimpleJSONClass();

            tmp.Add(aKey, aItem);
            Set(tmp);
        }
コード例 #2
0
ファイル: SimpleJSON.cs プロジェクト: SimonBellV/v0.93
 public override SimpleJSONNode this[string aKey]
 {
     get
     {
         return(new SimpleJSONLazyCreator(this, aKey));
     }
     set
     {
         var tmp = new SimpleJSONClass();
         tmp.Add(aKey, value);
         Set(tmp);
     }
 }
コード例 #3
0
ファイル: SimpleJSON.cs プロジェクト: SimonBellV/v0.93
        public static SimpleJSONNode Deserialize(System.IO.BinaryReader aReader)
        {
            SimpleJSONBinaryTag type = (SimpleJSONBinaryTag)aReader.ReadByte();

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

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

            case SimpleJSONBinaryTag.Value:
            {
                return(new SimpleJSONData(aReader.ReadString()));
            }

            case SimpleJSONBinaryTag.IntValue:
            {
                return(new SimpleJSONData(aReader.ReadInt32()));
            }

            case SimpleJSONBinaryTag.DoubleValue:
            {
                return(new SimpleJSONData(aReader.ReadDouble()));
            }

            case SimpleJSONBinaryTag.BoolValue:
            {
                return(new SimpleJSONData(aReader.ReadBoolean()));
            }

            case SimpleJSONBinaryTag.FloatValue:
            {
                return(new SimpleJSONData(aReader.ReadSingle()));
            }

            default:
            {
                throw new Exception("Error deserializing JSON. Unknown tag: " + type);
            }
            }
        }