public final class PrettyJsonFormatter extends java.lang.Object implements JsonFormatter
Constructor and Description |
---|
PrettyJsonFormatter()
Constructs a
JsonFormatter that formats JSON in a human-readable form, outputting the fields of objects in the order they were defined. |
Modifier and Type | Method and Description |
---|---|
static PrettyJsonFormatter |
fieldOrderNormalisingPrettyJsonFormatter()
Gets a
JsonFormatter that formats JSON in a human-readable form, outputting the fields of objects in alphabetic order. |
static PrettyJsonFormatter |
fieldOrderPreservingPrettyJsonFormatter()
Gets a
JsonFormatter that formats JSON in a human-readable form, outputting the fields of objects in the order they were defined. |
java.lang.String |
format(JsonNode jsonNode)
Returns the specified
JsonNode formatted as a String. |
void |
format(JsonNode jsonNode,
java.io.Writer writer)
Streams the specified
JsonNode formatted to the specified Writer . |
public PrettyJsonFormatter()
JsonFormatter
that formats JSON in a human-readable form, outputting the fields of objects in the order they were defined.public static PrettyJsonFormatter fieldOrderPreservingPrettyJsonFormatter()
JsonFormatter
that formats JSON in a human-readable form, outputting the fields of objects in the order they were defined.JsonFormatter
that formats JSON in a human-readable form, outputting the fields of objects in the order they were defined.public static PrettyJsonFormatter fieldOrderNormalisingPrettyJsonFormatter()
JsonFormatter
that formats JSON in a human-readable form, outputting the fields of objects in alphabetic order.JsonFormatter
that formats JSON in a human-readable form, outputting the fields of objects in alphabetic order.public java.lang.String format(JsonNode jsonNode)
JsonFormatter
JsonNode
formatted as a String.format
in interface JsonFormatter
jsonNode
- the JsonNode
to format.JsonNode
formatted as a String.public void format(JsonNode jsonNode, java.io.Writer writer) throws java.io.IOException
JsonFormatter
JsonNode
formatted to the specified Writer
.format
in interface JsonFormatter
jsonNode
- the JsonNode
to format.writer
- the Writer
to stream the formatted JsonNode
to.java.io.IOException
- if there was a problem writing to the Writer
.