Package org.beanio.stream.json
Class JsonWriterSupport
- java.lang.Object
-
- org.beanio.stream.json.JsonWriterSupport
-
- Direct Known Subclasses:
JsonRecordMarshaller
,JsonWriter
public abstract class JsonWriterSupport extends java.lang.Object
Base class for writing a JSON formatted stream. Theinit(Writer, JsonParserConfiguration)
method must be invoked before any writeXXX method.- Since:
- 2.0
- See Also:
JsonRecordParserFactory
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected int
getIndent()
protected java.lang.String
getLineSeparator()
protected void
init(java.io.Writer out, JsonParserConfiguration config)
Initializes this object.protected boolean
isPretty()
protected void
write(java.util.Map<java.lang.String,java.lang.Object> map)
Writes aMap
in JSON object format.protected void
writeArray(java.lang.Iterable<java.lang.Object> iterable)
Writes anIterable
in JSON array format.protected void
writeString(java.lang.String text)
Writes aString
in JSON string format.protected void
writeValue(java.lang.Object value)
Writes a value in JSON format.
-
-
-
Method Detail
-
init
protected void init(java.io.Writer out, JsonParserConfiguration config)
Initializes this object.- Parameters:
out
- theWriter
to write toconfig
- theJsonParserConfiguration
-
write
protected void write(java.util.Map<java.lang.String,java.lang.Object> map) throws java.io.IOException
Writes aMap
in JSON object format.- Parameters:
map
- the Map to write- Throws:
java.io.IOException
-
writeValue
protected void writeValue(java.lang.Object value) throws java.io.IOException
Writes a value in JSON format. The value must be aString
,Number
,Boolean
,Map
orIterable
(array), or elseObject.toString()
is called and the value is formatted as a JSON string.- Parameters:
value
- theObject
to write- Throws:
java.io.IOException
-
writeString
protected void writeString(java.lang.String text) throws java.io.IOException
Writes aString
in JSON string format.- Parameters:
text
- theString
to write- Throws:
java.io.IOException
-
writeArray
protected void writeArray(java.lang.Iterable<java.lang.Object> iterable) throws java.io.IOException
Writes anIterable
in JSON array format.- Parameters:
iterable
- theIterable
to write- Throws:
java.io.IOException
-
isPretty
protected boolean isPretty()
-
getIndent
protected int getIndent()
-
getLineSeparator
protected java.lang.String getLineSeparator()
-
-