Package org.springframework.boot.json
Interface WritableJson
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
JSON content that can be written out.
- Since:
- 3.4.0
- Author:
- Phillip Webb, Moritz Halbritter
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic WritableJsonof(WritableJson writableJson) Factory method used to create aWritableJsonwith a sensibleObject.toString()that delegate totoJsonString().voidto(Appendable out) Write the JSON to the providedAppendable.default byte[]Write the JSON to a UTF-8 encoded byte array.default byte[]toByteArray(Charset charset) Write the JSON to a byte array.default StringWrite the JSON to aString.default voidWrite the JSON to the providedOutputStreamusingUTF8encoding.default voidtoOutputStream(OutputStream out, Charset charset) Write the JSON to the providedOutputStreamusing the givenCharset.default voidWrite the JSON to the providedWritableResourceusingUTF8encoding.default voidtoResource(WritableResource out, Charset charset) Write the JSON to the providedWritableResourceusing the givenCharset.default voidWrite the JSON to the providedWriter.
-
Method Details
-
to
Write the JSON to the providedAppendable.- Parameters:
out- theAppendableto receive the JSON- Throws:
IOException- on IO error
-
toJsonString
Write the JSON to aString.- Returns:
- the JSON string
-
toByteArray
default byte[] toByteArray()Write the JSON to a UTF-8 encoded byte array.- Returns:
- the JSON bytes
-
toByteArray
Write the JSON to a byte array.- Parameters:
charset- the charset- Returns:
- the JSON bytes
-
toResource
Write the JSON to the providedWritableResourceusingUTF8encoding.- Parameters:
out- theOutputStreamto receive the JSON- Throws:
IOException- on IO error
-
toResource
Write the JSON to the providedWritableResourceusing the givenCharset.- Parameters:
out- theOutputStreamto receive the JSONcharset- the charset to use- Throws:
IOException- on IO error
-
toOutputStream
Write the JSON to the providedOutputStreamusingUTF8encoding. The output stream will not be closed.- Parameters:
out- theOutputStreamto receive the JSON- Throws:
IOException- on IO error- See Also:
-
toOutputStream
Write the JSON to the providedOutputStreamusing the givenCharset. The output stream will not be closed.- Parameters:
out- theOutputStreamto receive the JSONcharset- the charset to use- Throws:
IOException- on IO error
-
toWriter
Write the JSON to the providedWriter. The writer will be flushed but not closed.- Parameters:
out- theWriterto receive the JSON- Throws:
IOException- on IO error- See Also:
-
of
Factory method used to create aWritableJsonwith a sensibleObject.toString()that delegate totoJsonString().- Parameters:
writableJson- the sourceWritableJson- Returns:
- a new
WritableJsonwith a sensibleObject.toString().
-