public class JsonStreamWriter extends Object
Constructor and Description |
---|
JsonStreamWriter(OutputStream stream,
Charset encoding)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
flush()
Flush the output stream.
|
boolean |
getPretty()
Retrieve the pretty-print flag.
|
void |
setPretty(boolean pretty)
Set the pretty-print flag.
|
void |
writeEndList()
End writing a list.
|
void |
writeEndObject()
End writing an object.
|
void |
writeList(String name,
List<Object> values)
Write a named list attribute containing simple values.
|
void |
writeNameValuePair(String name,
boolean value)
Write a boolean attribute.
|
void |
writeNameValuePair(String name,
double value)
Write a double attribute.
|
void |
writeNameValuePair(String name,
int value)
Write an int attribute.
|
void |
writeNameValuePair(String name,
LocalDateTime value)
Write a Date attribute as a timestamp.
|
void |
writeNameValuePair(String name,
long value)
Write a long attribute.
|
void |
writeNameValuePair(String name,
String value)
Write a string attribute.
|
void |
writeNameValuePairAsDate(String name,
LocalDate value)
Write a date attribute.
|
void |
writeNameValuePairAsTime(String name,
LocalTime value)
Write a time attribute.
|
void |
writeStartList(String name)
Begin writing a named list attribute.
|
void |
writeStartObject(String name)
Begin writing a named object attribute.
|
public JsonStreamWriter(OutputStream stream, Charset encoding)
stream
- target output streamencoding
- target encodingpublic boolean getPretty()
public void setPretty(boolean pretty)
pretty
- true if pretty printing is enabledpublic void flush() throws IOException
IOException
public void writeStartObject(String name) throws IOException
name
- attribute nameIOException
public void writeList(String name, List<Object> values) throws IOException
name
- attribute namevalues
- list of attribute valuesIOException
public void writeStartList(String name) throws IOException
name
- attribute nameIOException
public void writeEndObject() throws IOException
IOException
public void writeEndList() throws IOException
IOException
public void writeNameValuePair(String name, String value) throws IOException
name
- attribute namevalue
- attribute valueIOException
public void writeNameValuePair(String name, int value) throws IOException
name
- attribute namevalue
- attribute valueIOException
public void writeNameValuePair(String name, long value) throws IOException
name
- attribute namevalue
- attribute valueIOException
public void writeNameValuePair(String name, double value) throws IOException
name
- attribute namevalue
- attribute valueIOException
public void writeNameValuePair(String name, boolean value) throws IOException
name
- attribute namevalue
- attribute valueIOException
public void writeNameValuePair(String name, LocalDateTime value) throws IOException
name
- attribute namevalue
- attribute valueIOException
public void writeNameValuePairAsDate(String name, LocalDate value) throws IOException
name
- attribute namevalue
- attribute valueIOException
public void writeNameValuePairAsTime(String name, LocalTime value) throws IOException
name
- attribute namevalue
- attribute valueIOException
Copyright © 2000–2024 Packwood Software. All rights reserved.