Exemplo n.º 1
0
    protected override string stringifyValue(int indentLevel, JSONStringifyOptions options)
    {
        var  t = new StringBuilder();
        bool hasItemsInList = false;

        t.Append(CHAR_START);

        foreach (KeyValuePair <string, object> valueItem in value)
        {
            if (hasItemsInList)
            {
                t.Append(CHAR_ITEM_SEPARATOR);
            }

            t.Append(options.lineFeed + JSONEncoder.getIndents(options.individualIndent, indentLevel + 1));
            t.Append(JSONEncoder.encode(valueItem.Key, 0, options));
            t.Append(options.objectAfterKey + CHAR_KEY_SEPARATOR + options.objectBeforeValue);
            t.Append(JSONEncoder.encode(valueItem.Value, indentLevel + 1, options));

            hasItemsInList = true;
        }

        t.Append(options.lineFeed + JSONEncoder.getIndents(options.individualIndent, indentLevel));
        t.Append(CHAR_END);

        return(t.ToString());
    }
Exemplo n.º 2
0
    protected override string stringifyValue(int indentLevel, JSONStringifyOptions options)
    {
        var  t = new StringBuilder();
        bool hasItemsInList = false;

        t.Append(CHAR_START);

        foreach (object valueItem in value)
        {
            if (hasItemsInList)
            {
                t.Append(CHAR_ITEM_SEPARATOR);
            }

            if (options.lineFeedOnArrays)
            {
                t.Append(options.lineFeed + JSONEncoder.getIndents(options.individualIndent, indentLevel + 1));
            }
            else
            {
                t.Append(options.arrayAfterSeparator);
            }
            t.Append(JSONEncoder.encode(valueItem, indentLevel + 1, options));

            hasItemsInList = true;
        }

        t.Append(options.lineFeed + JSONEncoder.getIndents(options.individualIndent, indentLevel));
        t.Append(CHAR_END);

        return(t.ToString());
    }