Package org.eclipse.parsson
Class JsonPrettyGeneratorImpl
java.lang.Object
org.eclipse.parsson.JsonPrettyGeneratorImpl
- All Implemented Interfaces:
JsonGenerator,Closeable,Flushable,AutoCloseable
- Author:
- Jitendra Kotamraju
-
Field Summary
Fields inherited from interface jakarta.json.stream.JsonGenerator
PRETTY_PRINTING -
Constructor Summary
ConstructorsConstructorDescriptionJsonPrettyGeneratorImpl(OutputStream out, Charset encoding, org.eclipse.parsson.JsonContext jsonContext) JsonPrettyGeneratorImpl(OutputStream out, org.eclipse.parsson.JsonContext jsonContext) JsonPrettyGeneratorImpl(Writer writer, org.eclipse.parsson.JsonContext jsonContext) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this generator and frees any resources associated with it.voidflush()Flushes the underlying output source.protected booleaninNone()write(boolean value) Writes a JSON true or false value within the current array, field or root context.write(double value) Writes the specified value as a JSON number value within the current array, field or root context.write(int value) Writes the specified value as a JSON number value within the current array, field or root context.write(long value) Writes the specified value as a JSON number value within the current array, field or root context.Writes the specified value as a JSON value within the current array, field or root context.Writes the specified value as a JSON string value within the current array, field or root context.Writes a JSON name/boolean value pair in the current object context.Writes a JSON name/number value pair in the current object context.Writes a JSON name/number value pair in the current object context.Writes a JSON name/number value pair in the current object context.Writes a JSON name/value pair in the current object context.Writes a JSON name/string value pair in the current object context.write(String name, BigDecimal value) Writes a JSON name/number value pair in the current object context.write(String name, BigInteger value) Writes a JSON name/number value pair in the current object context.write(BigDecimal value) Writes the specified value as a JSON number value within the current array, field or root context.write(BigInteger value) Writes the specified value as a JSON number value within the current array, field or root context.protected voidprotected voidwriteEnd()Writes the end of the current context.Writes the JSON name with a colon.Writes a JSON null value within the current array, field or root context.Writes a JSON name/null value pair in an current object context.Writes the JSON start array character.writeStartArray(String name) Writes the JSON name/start array character pair with in the current object context.Writes the JSON start object character.writeStartObject(String name) Writes the JSON name/start object character pair in the current object context.
-
Constructor Details
-
JsonPrettyGeneratorImpl
-
JsonPrettyGeneratorImpl
-
JsonPrettyGeneratorImpl
public JsonPrettyGeneratorImpl(OutputStream out, Charset encoding, org.eclipse.parsson.JsonContext jsonContext)
-
-
Method Details
-
writeStartObject
Description copied from interface:JsonGeneratorWrites the JSON start object character. It starts a new child object context within which JSON name/value pairs can be written to the object. This method is valid only in an array context, field context or in no context (when a context is not yet started). This method can only be called once in no context.- Specified by:
writeStartObjectin interfaceJsonGenerator- Returns:
- this generator
-
writeStartObject
Description copied from interface:JsonGeneratorWrites the JSON name/start object character pair in the current object context. It starts a new child object context within which JSON name/value pairs can be written to the object.- Specified by:
writeStartObjectin interfaceJsonGenerator- Parameters:
name- a name within the JSON name/object pair to be written- Returns:
- this generator
-
writeStartArray
Description copied from interface:JsonGeneratorWrites the JSON start array character. It starts a new child array context within which JSON values can be written to the array. This method is valid only in an array context, field context or in no context (when a context is not yet started). This method can only be called once in no context.- Specified by:
writeStartArrayin interfaceJsonGenerator- Returns:
- this generator
-
writeStartArray
Description copied from interface:JsonGeneratorWrites the JSON name/start array character pair with in the current object context. It starts a new child array context within which JSON values can be written to the array.- Specified by:
writeStartArrayin interfaceJsonGenerator- Parameters:
name- a name within the JSON name/array pair to be written- Returns:
- this generator
-
writeEnd
Description copied from interface:JsonGeneratorWrites the end of the current context. If the current context is an array context, this method writes the end-of-array character (']'). If the current context is an object context, this method writes the end-of-object character ('}'). After writing the end of the current context, the parent context becomes the new current context. If parent context is field context, it is closed.- Specified by:
writeEndin interfaceJsonGenerator- Returns:
- this generator
-
writeComma
protected void writeComma() -
writeColon
protected void writeColon() -
flush
public void flush()Description copied from interface:JsonGeneratorFlushes the underlying output source. If the generator has saved any characters in a buffer, writes them immediately to the underlying output source before flushing it.- Specified by:
flushin interfaceFlushable- Specified by:
flushin interfaceJsonGenerator
-
write
Description copied from interface:JsonGeneratorWrites a JSON name/string value pair in the current object context. The specified value is written as JSON string value.- Specified by:
writein interfaceJsonGenerator- Parameters:
name- a name in the JSON name/string pair to be written in current JSON objectfieldValue- a value in the JSON name/string pair to be written in current JSON object- Returns:
- this generator
-
write
Description copied from interface:JsonGeneratorWrites a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The stringnew BigDecimal(value).toString()is used as the text value for writing.- Specified by:
writein interfaceJsonGenerator- Parameters:
name- a name in the JSON name/number pair to be written in current JSON objectvalue- a value in the JSON name/number pair to be written in current JSON object- Returns:
- this generator
-
write
Description copied from interface:JsonGeneratorWrites a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The stringnew BigDecimal(value).toString()is used as the text value for writing.- Specified by:
writein interfaceJsonGenerator- Parameters:
name- a name in the JSON name/number pair to be written in current JSON objectvalue- a value in the JSON name/number pair to be written in current JSON object- Returns:
- this generator
-
write
Description copied from interface:JsonGeneratorWrites a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The stringBigDecimal.valueOf(double).toString()is used as the text value for writing.- Specified by:
writein interfaceJsonGenerator- Parameters:
name- a name in the JSON name/number pair to be written in current JSON objectvalue- a value in the JSON name/number pair to be written in current JSON object- Returns:
- this generator
-
write
Description copied from interface:JsonGeneratorWrites a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The stringnew BigDecimal(value).toString()is used as the text value for writing.- Specified by:
writein interfaceJsonGenerator- Parameters:
name- a name in the JSON name/number pair to be written in current JSON objectvalue- a value in the JSON name/number pair to be written in current JSON object- Returns:
- this generator
-
write
Description copied from interface:JsonGeneratorWrites a JSON name/number value pair in the current object context. The specified value is written as a JSON number value. The specified value'stoString()is used as the text value for writing.- Specified by:
writein interfaceJsonGenerator- Parameters:
name- a name in the JSON name/number pair to be written in current JSON objectvalue- a value in the JSON name/number pair to be written in current JSON object- Returns:
- this generator
-
write
Description copied from interface:JsonGeneratorWrites a JSON name/boolean value pair in the current object context. If value is true, it writes the JSONtruevalue, otherwise it writes the JSONfalsevalue.- Specified by:
writein interfaceJsonGenerator- Parameters:
name- a name in the JSON name/boolean pair to be written in current JSON objectvalue- a value in the JSON name/boolean pair to be written in current JSON object- Returns:
- this generator
-
writeNull
Description copied from interface:JsonGeneratorWrites a JSON name/null value pair in an current object context.- Specified by:
writeNullin interfaceJsonGenerator- Parameters:
name- a name in the JSON name/null pair to be written in current JSON object- Returns:
- this generator
-
write
Description copied from interface:JsonGeneratorWrites the specified value as a JSON value within the current array, field or root context.- Specified by:
writein interfaceJsonGenerator- Parameters:
value- a value to be written in current JSON array- Returns:
- this generator
-
write
Description copied from interface:JsonGeneratorWrites a JSON name/value pair in the current object context.- Specified by:
writein interfaceJsonGenerator- Parameters:
name- a name in the JSON name/value pair to be written in current JSON objectvalue- a value in the JSON name/value pair to be written in current JSON object- Returns:
- this generator
-
write
Description copied from interface:JsonGeneratorWrites the specified value as a JSON string value within the current array, field or root context.- Specified by:
writein interfaceJsonGenerator- Parameters:
value- a value to be written in current JSON array- Returns:
- this generator
-
write
Description copied from interface:JsonGeneratorWrites the specified value as a JSON number value within the current array, field or root context. The stringnew BigDecimal(value).toString()is used as the text value for writing.- Specified by:
writein interfaceJsonGenerator- Parameters:
value- a value to be written in current JSON array- Returns:
- this generator
-
write
Description copied from interface:JsonGeneratorWrites the specified value as a JSON number value within the current array, field or root context. The stringnew BigDecimal(value).toString()is used as the text value for writing.- Specified by:
writein interfaceJsonGenerator- Parameters:
value- a value to be written in current JSON array- Returns:
- this generator
-
write
Description copied from interface:JsonGeneratorWrites the specified value as a JSON number value within the current array, field or root context. The stringBigDecimal.valueOf(value).toString()is used as the text value for writing.- Specified by:
writein interfaceJsonGenerator- Parameters:
value- a value to be written in current JSON array- Returns:
- this generator
-
write
Description copied from interface:JsonGeneratorWrites the specified value as a JSON number value within the current array, field or root context. The stringnew BigDecimal(value).toString()is used as the text value for writing.- Specified by:
writein interfaceJsonGenerator- Parameters:
value- a value to be written in current JSON array- Returns:
- this generator.
- See Also:
-
write
Description copied from interface:JsonGeneratorWrites the specified value as a JSON number value within the current array, field or root context. The specified value'stoString()is used as the the text value for writing.- Specified by:
writein interfaceJsonGenerator- Parameters:
value- a value to be written in current JSON array- Returns:
- this generator
- See Also:
-
write
Description copied from interface:JsonGeneratorWrites a JSON true or false value within the current array, field or root context. If value is true, this method writes the JSONtruevalue, otherwise it writes the JSONfalsevalue.- Specified by:
writein interfaceJsonGenerator- Parameters:
value- abooleanvalue- Returns:
- this generator
-
writeNull
Description copied from interface:JsonGeneratorWrites a JSON null value within the current array, field or root context.- Specified by:
writeNullin interfaceJsonGenerator- Returns:
- this generator
-
writeKey
Description copied from interface:JsonGeneratorWrites the JSON name with a colon. It starts a field context, in which valid options are writing a value, starting an object or an array. Writing value closes field context, if object or array is started after field name, field context will be closed after object/array close.- Specified by:
writeKeyin interfaceJsonGenerator- Parameters:
name- name of json field- Returns:
- this generator
-
inNone
protected boolean inNone() -
close
public void close()Description copied from interface:JsonGeneratorCloses this generator and frees any resources associated with it. This method closes the underlying output source. The underlying stream is closed only if complete JSON object is written. In case of incomplete object JsonGenerationException is thrown and underlying stream is not closed.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceJsonGenerator
-