All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.jayway.jsonpath.internal.JsonFormatter Maven / Gradle / Ivy

There is a newer version: 2.9.0
Show newest version
package com.jayway.jsonpath.internal;

public class JsonFormatter
{
    private static final String INDENT = "   ";

    private static final String NEW_LINE = System.getProperty("line.separator");

    private static void appendIndent(StringBuilder sb, int count)
    {
        for (; count > 0; --count) sb.append(INDENT);
    }

    private static boolean isEscaped(StringBuilder sb, int index)
    {
        boolean escaped = false;
        while (index > 0 && sb.charAt(--index) == '\\') escaped = !escaped;
        return escaped;
    }

    public static String prettyPrint(String input)
    {
        StringBuilder output = new StringBuilder(input.length() * 2);
        boolean quoteOpened = false;
        int depth = 0;

        for(int i=0; i




© 2015 - 2024 Weber Informatics LLC | Privacy Policy