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 SummaryModifier 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- 
toWrite the JSON to the providedAppendable.- Parameters:
- out- the- Appendableto receive the JSON
- Throws:
- IOException- on IO error
 
- 
toJsonStringWrite the JSON to aString.- Returns:
- the JSON string
 
- 
toByteArraydefault byte[] toByteArray()Write the JSON to a UTF-8 encoded byte array.- Returns:
- the JSON bytes
 
- 
toByteArrayWrite the JSON to a byte array.- Parameters:
- charset- the charset
- Returns:
- the JSON bytes
 
- 
toResourceWrite the JSON to the providedWritableResourceusingUTF8encoding.- Parameters:
- out- the- OutputStreamto receive the JSON
- Throws:
- IOException- on IO error
 
- 
toResourceWrite the JSON to the providedWritableResourceusing the givenCharset.- Parameters:
- out- the- OutputStreamto receive the JSON
- charset- the charset to use
- Throws:
- IOException- on IO error
 
- 
toOutputStreamWrite the JSON to the providedOutputStreamusingUTF8encoding. The output stream will not be closed.- Parameters:
- out- the- OutputStreamto receive the JSON
- Throws:
- IOException- on IO error
- See Also:
 
- 
toOutputStreamWrite the JSON to the providedOutputStreamusing the givenCharset. The output stream will not be closed.- Parameters:
- out- the- OutputStreamto receive the JSON
- charset- the charset to use
- Throws:
- IOException- on IO error
 
- 
toWriterWrite the JSON to the providedWriter. The writer will be flushed but not closed.- Parameters:
- out- the- Writerto receive the JSON
- Throws:
- IOException- on IO error
- See Also:
 
- 
ofFactory method used to create aWritableJsonwith a sensibleObject.toString()that delegate totoJsonString().- Parameters:
- writableJson- the source- WritableJson
- Returns:
- a new WritableJsonwith a sensibleObject.toString().
 
 
-