Пример #1
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var arr = new MutableArrayObject();

            while (reader.Read())
            {
                if (reader.TokenType == JsonToken.EndObject)
                {
                    var val = serializer.Deserialize(reader) as IDictionary <string, object>;
                    if (val.ContainsKey(Constants.ObjectTypeProperty) &&
                        val[Constants.ObjectTypeProperty].Equals(Constants.ObjectTypeBlob))
                    {
                        var blob = serializer.Deserialize <Blob>(reader);
                        arr.AddBlob(blob);
                    }
                    else
                    {
                        var dict = serializer.Deserialize <MutableDictionaryObject>(reader);
                        arr.AddValue(dict);
                    }
                }
                else if (reader.TokenType == JsonToken.EndArray)
                {
                    var array = serializer.Deserialize <MutableArrayObject>(reader);
                    arr.AddValue(array);
                }
                else
                {
                    arr.AddValue(reader.Value);
                }
            }

            return(arr);
        }
Пример #2
0
        public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
        {
            var arr = new MutableArrayObject();

            while (reader.Read())
            {
                arr.AddValue(serializer.Deserialize(reader));
            }

            return(arr);
        }