Class JsonOutput
java.lang.Object
se.l4.commons.serialization.format.JsonOutput
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable,StreamingOutput
public class JsonOutput extends Object implements StreamingOutput
Streamer that outputs JSON.
- Author:
- andreas
-
Field Summary
-
Constructor Summary
Constructors Constructor Description JsonOutput(OutputStream out)Create a JSON streamer that will write to the given output.JsonOutput(OutputStream out, boolean beautify)Create a JSON streamer that will write to the given output, optionally with beautification of the generated JSON.JsonOutput(Writer writer)Create a JSON streamer that will write to the given output.JsonOutput(Writer writer, boolean beautify)Create a JSON streamer that will write to the given output, optionally with beautification of the generated JSON. -
Method Summary
Modifier and Type Method Description voidclose()voidflush()voidwrite(String name, boolean bool)Write a boolean.voidwrite(String name, byte[] data)Write a byte array to the output.voidwrite(String name, double number)Write a double.voidwrite(String name, float number)Write a float.voidwrite(String name, int number)Write an integer.voidwrite(String name, long number)Write a long.voidwrite(String name, String value)Write a string.voidwriteListEnd(String name)Write the end of a list.voidwriteListStart(String name)Write the start of a list.voidwriteNull(String name)Write a null value.voidwriteObjectEnd(String name)Write the end of an object.voidwriteObjectStart(String name)Write the start of an object.
-
Field Details
-
Constructor Details
-
JsonOutput
Create a JSON streamer that will write to the given output.- Parameters:
out-
-
JsonOutput
Create a JSON streamer that will write to the given output, optionally with beautification of the generated JSON.- Parameters:
out-beautify-
-
JsonOutput
Create a JSON streamer that will write to the given output.- Parameters:
out-
-
JsonOutput
Create a JSON streamer that will write to the given output, optionally with beautification of the generated JSON.- Parameters:
out-beautify-
-
-
Method Details
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
writeObjectStart
Description copied from interface:StreamingOutputWrite the start of an object.- Specified by:
writeObjectStartin interfaceStreamingOutput- Throws:
IOException
-
writeObjectEnd
Description copied from interface:StreamingOutputWrite the end of an object.- Specified by:
writeObjectEndin interfaceStreamingOutput- Throws:
IOException
-
writeListStart
Description copied from interface:StreamingOutputWrite the start of a list.- Specified by:
writeListStartin interfaceStreamingOutput- Throws:
IOException
-
writeListEnd
Description copied from interface:StreamingOutputWrite the end of a list.- Specified by:
writeListEndin interfaceStreamingOutput- Throws:
IOException
-
write
Description copied from interface:StreamingOutputWrite a string.- Specified by:
writein interfaceStreamingOutput- Throws:
IOException
-
write
Description copied from interface:StreamingOutputWrite an integer.- Specified by:
writein interfaceStreamingOutput- Throws:
IOException
-
write
Description copied from interface:StreamingOutputWrite a long.- Specified by:
writein interfaceStreamingOutput- Throws:
IOException
-
write
Description copied from interface:StreamingOutputWrite a float.- Specified by:
writein interfaceStreamingOutput- Throws:
IOException
-
write
Description copied from interface:StreamingOutputWrite a double.- Specified by:
writein interfaceStreamingOutput- Throws:
IOException
-
write
Description copied from interface:StreamingOutputWrite a boolean.- Specified by:
writein interfaceStreamingOutput- Throws:
IOException
-
write
Description copied from interface:StreamingOutputWrite a byte array to the output.- Specified by:
writein interfaceStreamingOutput- Throws:
IOException
-
writeNull
Description copied from interface:StreamingOutputWrite a null value.- Specified by:
writeNullin interfaceStreamingOutput- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Throws:
IOException
-