Class JsonWriter
java.lang.Object
com.aquima.interactions.foundation.json.writer.JsonWriter
- All Implemented Interfaces:
IJsonWriter
Class to write Json objects to a stream writer.
- Since:
- 7.0
- Author:
- J. Gorter, Jon van Leuven
-
Constructor Summary
ConstructorDescriptionJsonWriter
(Writer writer, boolean useIndentation) This construct a Json writer with a writer. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Close this (and its internal) writer.void
End appending an array.void
Begin appending an array.void
writeArrayStart
(String memberName) Begin appending an array with a name.void
writeMember
(String memberName) Appending a member.void
writeMember
(String memberName, boolean booleanValue) Append a member with a boolean value.void
writeMember
(String memberName, double doubleValue) Append a member with a double value.void
writeMember
(String memberName, long longValue) Append a member with a long value.void
writeMember
(String memberName, String strValue) Append a member with a string value.void
Append a member with a null value.void
End appending an object.void
Begin appending an object.void
writeObjectStart
(String memberName) Begin appending an object with a name.void
writeValue
(boolean booleanValue) Append a boolean value.void
writeValue
(double doubleValue) Append a double value.void
writeValue
(long longValue) Append a long value.void
writeValue
(String strValue) Append a string value.void
Append a null value.
-
Constructor Details
-
JsonWriter
This construct a Json writer with a writer.- Parameters:
writer
- The writer to write json result to.useIndentation
- true to use whitespace indentation for pretty printing.
-
-
Method Details
-
close
Close this (and its internal) writer.- Specified by:
close
in interfaceIJsonWriter
- Throws:
IOException
- If an I/O error occurs.
-
writeObjectStart
Begin appending an object.- Specified by:
writeObjectStart
in interfaceIJsonWriter
- Throws:
IOException
- If an I/O error occurs.
-
writeObjectStart
Begin appending an object with a name.- Specified by:
writeObjectStart
in interfaceIJsonWriter
- Parameters:
memberName
- The member name, may not be null or empty.- Throws:
IOException
- If an I/O error occurs.
-
writeObjectEnd
End appending an object.- Specified by:
writeObjectEnd
in interfaceIJsonWriter
- Throws:
IOException
- If an I/O error occurs.
-
writeMember
Appending a member.- Specified by:
writeMember
in interfaceIJsonWriter
- Parameters:
memberName
- The member name, may not be null or empty.- Throws:
IOException
- If an I/O error occurs.
-
writeMember
Append a member with a long value.- Specified by:
writeMember
in interfaceIJsonWriter
- Parameters:
memberName
- The member name, may not be null or empty.longValue
- The value of the member.- Throws:
IOException
- If an I/O error occurs.
-
writeMember
Append a member with a double value.- Specified by:
writeMember
in interfaceIJsonWriter
- Parameters:
memberName
- The member name, may not be null or empty.doubleValue
- The value of the member.- Throws:
IOException
- If an I/O error occurs.
-
writeMember
Append a member with a boolean value.- Specified by:
writeMember
in interfaceIJsonWriter
- Parameters:
memberName
- The member name, may not be null or empty.booleanValue
- The value of the member.- Throws:
IOException
- If an I/O error occurs.
-
writeMember
Append a member with a string value.- Specified by:
writeMember
in interfaceIJsonWriter
- Parameters:
memberName
- The member name, may not be null or empty.strValue
- The value of the member.- Throws:
IOException
- If an I/O error occurs.
-
writeNull
Append a member with a null value.- Specified by:
writeNull
in interfaceIJsonWriter
- Parameters:
memberName
- The member name, may not be null or empty.- Throws:
IOException
- If an I/O error occurs.
-
writeValue
Append a long value.- Specified by:
writeValue
in interfaceIJsonWriter
- Parameters:
longValue
- The value.- Throws:
IOException
- If an I/O error occurs.
-
writeValue
Append a double value.- Specified by:
writeValue
in interfaceIJsonWriter
- Parameters:
doubleValue
- The value.- Throws:
IOException
- If an I/O error occurs.
-
writeValue
Append a boolean value.- Specified by:
writeValue
in interfaceIJsonWriter
- Parameters:
booleanValue
- The value.- Throws:
IOException
- If an I/O error occurs.
-
writeValue
Append a string value.- Specified by:
writeValue
in interfaceIJsonWriter
- Parameters:
strValue
- The value.- Throws:
IOException
- If an I/O error occurs.
-
writeValueNull
Append a null value.- Specified by:
writeValueNull
in interfaceIJsonWriter
- Throws:
IOException
- If an I/O error occurs.
-
writeArrayStart
Begin appending an array.- Specified by:
writeArrayStart
in interfaceIJsonWriter
- Throws:
IOException
- If an I/O error occurs.
-
writeArrayStart
Begin appending an array with a name.- Specified by:
writeArrayStart
in interfaceIJsonWriter
- Parameters:
memberName
- The member name, may not be null or empty.- Throws:
IOException
- If an I/O error occurs.
-
writeArrayEnd
End appending an array.- Specified by:
writeArrayEnd
in interfaceIJsonWriter
- Throws:
IOException
- If an I/O error occurs.
-