public final class JsonGenerator
extends java.lang.Object
Strings of valid JSON and to stream valid JSON text to a java.io.Writer.
 Instances of this class are immutable, reusable, and thread-safe.
| Modifier and Type | Class and Description | 
|---|---|
| static class  | JsonGenerator.JsonGeneratorStyleStyles of output a  JsonGeneratorcan produce. | 
| Constructor and Description | 
|---|
| JsonGenerator() | 
| Modifier and Type | Method and Description | 
|---|---|
| java.lang.String | generate(JsonNode jsonNode)Generates a JSON representation of the given  JsonNodeas aString. | 
| java.lang.String | generate(WriteableJsonArray writeableJsonArray)Generates a JSON representation of the given  WriteableJsonArrayas aString. | 
| java.lang.String | generate(WriteableJsonNumber writeableJsonNumber)Generates a JSON representation of the given  WriteableJsonNumberas aString. | 
| java.lang.String | generate(WriteableJsonObject writeableJsonObject)Generates a JSON representation of the given  WriteableJsonObjectas aString. | 
| java.lang.String | generate(WriteableJsonString writeableJsonString)Generates a JSON representation of the given  WriteableJsonStringas aString. | 
| void | generate(java.io.Writer target,
        JsonNode jsonNode)Streams a JSON representation of the given  JsonNodeto the givenWriter. | 
| void | generate(java.io.Writer target,
        WriteableJsonArray writeableJsonArray)Streams a JSON representation of the given  WriteableJsonArrayto the givenWriter. | 
| void | generate(java.io.Writer target,
        WriteableJsonNumber writeableJsonNumber)Streams a JSON representation of the given  WriteableJsonNumberto the givenWriter. | 
| void | generate(java.io.Writer target,
        WriteableJsonObject writeableJsonObject)Streams a JSON representation of the given  WriteableJsonObjectto the givenWriter. | 
| void | generate(java.io.Writer target,
        WriteableJsonString writeableJsonString)Streams a JSON representation of the given  WriteableJsonStringto the givenWriter. | 
| java.lang.String | generateWithFieldSorting(JsonNode jsonNode)Generates a JSON representation of the given  JsonNodeas aString, outputting fields in lexicographic order. | 
| void | generateWithFieldSorting(java.io.Writer target,
                        JsonNode jsonNode)Streams a JSON representation of the given  JsonNodeto the givenWriter, outputting fields in lexicographic order. | 
| JsonGenerator | style(JsonGenerator.JsonGeneratorStyle style)Returns a  JsonGeneratorwith the given output style. | 
public void generate(java.io.Writer target,
                     WriteableJsonArray writeableJsonArray)
              throws java.io.IOException
WriteableJsonArray to the given Writer.target - the Writer to output to.writeableJsonArray - the WriteableJsonArray to output.java.io.IOException - if there was a problem writing to the Writer.public java.lang.String generate(WriteableJsonArray writeableJsonArray) throws java.io.IOException
WriteableJsonArray as a String.writeableJsonArray - the WriteableJsonArray to output.WriteableJsonArray as a Stringjava.io.IOException - propagated from WriteableJsonArray.writeTo(ArrayWriter).public void generate(java.io.Writer target,
                     WriteableJsonObject writeableJsonObject)
              throws java.io.IOException
WriteableJsonObject to the given Writer.target - the Writer to output to.writeableJsonObject - the WriteableJsonObject to output.java.io.IOException - if there was a problem writing to the Writer.public java.lang.String generate(WriteableJsonObject writeableJsonObject) throws java.io.IOException
WriteableJsonObject as a String.writeableJsonObject - the WriteableJsonObject to output.WriteableJsonObject as a Stringjava.io.IOException - propagated from WriteableJsonObject.writeTo(ObjectWriter).public void generate(java.io.Writer target,
                     WriteableJsonString writeableJsonString)
              throws java.io.IOException
WriteableJsonString to the given Writer.target - the Writer to output to.writeableJsonString - the WriteableJsonString to output.java.io.IOException - if there was a problem writing to the Writer.public java.lang.String generate(WriteableJsonString writeableJsonString) throws java.io.IOException
WriteableJsonString as a String.writeableJsonString - the WriteableJsonString to output.WriteableJsonString as a Stringjava.io.IOException - propagated from WriteableJsonString.writeTo(Writer).public void generate(java.io.Writer target,
                     WriteableJsonNumber writeableJsonNumber)
              throws java.io.IOException
WriteableJsonNumber to the given Writer.target - the Writer to output to.writeableJsonNumber - the WriteableJsonNumber to output.java.io.IOException - if there was a problem writing to the Writer.java.lang.IllegalArgumentException - if the characters written by the WriteableJsonNumber don't constitute a complete JSON number.public java.lang.String generate(WriteableJsonNumber writeableJsonNumber) throws java.io.IOException
WriteableJsonNumber as a String.writeableJsonNumber - the WriteableJsonNumber to output.WriteableJsonNumber as a Stringjava.io.IOException - propagated from WriteableJsonNumber.writeTo(Writer).java.lang.IllegalArgumentException - if the characters written by the WriteableJsonNumber don't constitute a complete JSON number.public void generate(java.io.Writer target,
                     JsonNode jsonNode)
              throws java.io.IOException
JsonNode to the given Writer.target - the Writer to output to.jsonNode - the JsonNode to output.java.io.IOException - if there was a problem writing to the Writer.public java.lang.String generate(JsonNode jsonNode)
JsonNode as a String.jsonNode - the JsonNode to output.JsonNode as a Stringpublic void generateWithFieldSorting(java.io.Writer target,
                                     JsonNode jsonNode)
                              throws java.io.IOException
JsonNode to the given Writer, outputting fields in lexicographic order.
 JSON does not mandate a particular ordering for the fields of an object, but for comparing JSON documents it can be convenient for field order to be consistent.
 In the event that more than one field with the same name exists in an object, the relative order of those fields is preserved.target - the Writer to output to.jsonNode - the JsonNode to output.java.io.IOException - if there was a problem writing to the Writer.public java.lang.String generateWithFieldSorting(JsonNode jsonNode)
JsonNode as a String, outputting fields in lexicographic order.
 JSON does not mandate a particular ordering for the fields of an object, but for comparing JSON documents it can be convenient for field order to be consistent.
 In the event that more than one field with the same name exists in an object, the relative order of those fields is preserved.jsonNode - the JsonNode to output.JsonNode as a Stringpublic JsonGenerator style(JsonGenerator.JsonGeneratorStyle style)
JsonGenerator with the given output style.
 Defaults to JsonGenerator.JsonGeneratorStyle.PRETTY.style - the style of output to produce.JsonGenerator with the given output style.