示例#1
0
 public virtual VPackParser registerDeserializer(string attribute
                                                 , ValueType type, VPackJsonDeserializer
                                                 deserializer)
 {
     System.Collections.Generic.IDictionary <ValueType, VPackJsonDeserializer
                                             > byName = this.deserializersByName[attribute];
     if (byName == null)
     {
         byName = new System.Collections.Generic.Dictionary <ValueType
                                                             , VPackJsonDeserializer>();
         this.deserializersByName[attribute] = byName;
     }
     byName[type] = deserializer;
     return(this);
 }
示例#2
0
        private VPackJsonDeserializer getDeserializer(string attribute
                                                      , ValueType type)
        {
            VPackJsonDeserializer deserializer = null;

            System.Collections.Generic.IDictionary <ValueType, VPackJsonDeserializer
                                                    > byName = this.deserializersByName[attribute];
            if (byName != null)
            {
                deserializer = byName[type];
            }
            if (deserializer == null)
            {
                deserializer = this.deserializers[type];
            }
            return(deserializer);
        }
示例#3
0
 public virtual VPackParser registerDeserializer(ValueType
                                                 type, VPackJsonDeserializer deserializer)
 {
     this.deserializers[type] = deserializer;
     return(this);
 }
示例#4
0
        /// <exception cref="VPackException"/>
        private void parse(VPackSlice parent, string attribute, VPackSlice
                           value, java.lang.StringBuilder json, bool includeNullValues)
        {
            VPackJsonDeserializer deserializer = null;

            if (attribute != null)
            {
                appendField(attribute, json);
                deserializer = this.getDeserializer(attribute, value.type());
            }
            if (deserializer != null)
            {
                deserializer.deserialize(parent, attribute, value, json);
            }
            else
            {
                if (value.isObject())
                {
                    this.parseObject(value, json, includeNullValues);
                }
                else
                {
                    if (value.isArray())
                    {
                        this.parseArray(value, json, includeNullValues);
                    }
                    else
                    {
                        if (value.isBoolean())
                        {
                            json.Append(value.getAsBoolean());
                        }
                        else
                        {
                            if (value.isString())
                            {
                                json.Append(org.json.simple.JSONValue.toJSONString(value.getAsString()));
                            }
                            else
                            {
                                if (value.isNumber())
                                {
                                    json.Append(value.getAsNumber());
                                }
                                else
                                {
                                    if (value.isNull())
                                    {
                                        json.Append(NULL);
                                    }
                                    else
                                    {
                                        json.Append(org.json.simple.JSONValue.toJSONString(NON_REPRESENTABLE_TYPE));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }