com.jayway.jsonpath.internal.JsonFormatter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of json-path Show documentation
Show all versions of json-path Show documentation
Java port of Stefan Goessner JsonPath.
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