コード例 #1
0
        /// <exception cref="VPackException"/>
        private void parseArray(VPackSlice value, java.lang.StringBuilder
                                json, bool includeNullValues)
        {
            json.Append(ARRAY_OPEN);
            int added = 0;

            for (int i = 0; i < value.getLength(); i++)
            {
                VPackSlice valueAt = value.get(i);
                if (!valueAt.isNull() || includeNullValues)
                {
                    if (added++ > 0)
                    {
                        json.Append(SEPARATOR);
                    }
                    this.parse(value, null, valueAt, json, includeNullValues);
                }
            }
            json.Append(ARRAY_CLOSE);
        }
コード例 #2
0
        /// <exception cref="VPackException"/>
        private void parseObject(VPackSlice value, java.lang.StringBuilder
                                 json, bool includeNullValues)
        {
            json.Append(OBJECT_OPEN);
            int added = 0;

            for (System.Collections.Generic.IEnumerator <KeyValuePair <string, VPackSlice> > iterator = value.objectIterator();
                 iterator.MoveNext();)
            {
                System.Collections.Generic.KeyValuePair <string, VPackSlice
                                                         > next = iterator.Current;
                VPackSlice nextValue = next.Value;
                if (!nextValue.isNull() || includeNullValues)
                {
                    if (added++ > 0)
                    {
                        json.Append(SEPARATOR);
                    }
                    this.parse(value, next.Key, nextValue, json, includeNullValues);
                }
            }
            json.Append(OBJECT_CLOSE);
        }
コード例 #3
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));
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }