T - type of object to write as json representationpublic class JsonFileItemWriter<T> extends AbstractFileItemWriter<T>
Resource and must represent a
writable file. Items are transformed to json format using a
JsonObjectMarshaller. Items will be enclosed in a json array as follows:
[
{json object},
{json object},
{json object}
]
GsonJsonObjectMarshaller,
JacksonJsonObjectMarshallerAbstractFileItemWriter.OutputStateappend, DEFAULT_CHARSET, DEFAULT_LINE_SEPARATOR, DEFAULT_TRANSACTIONAL, lineSeparator, logger, shouldDeleteIfExists, state| Constructor and Description |
|---|
JsonFileItemWriter(org.springframework.core.io.Resource resource,
JsonObjectMarshaller<T> jsonObjectMarshaller)
Create a new
JsonFileItemWriter instance. |
| Modifier and Type | Method and Description |
|---|---|
void |
afterPropertiesSet()
Assert that mandatory properties (jsonObjectMarshaller) are set.
|
java.lang.String |
doWrite(java.util.List<? extends T> items)
Write out a string of items followed by a "new line", where the format of the new
line separator is determined by the underlying operating system.
|
void |
setJsonObjectMarshaller(JsonObjectMarshaller<T> jsonObjectMarshaller)
Set the
JsonObjectMarshaller to use to marshal object to json. |
close, getOutputState, open, setAppendAllowed, setEncoding, setFooterCallback, setForceSync, setHeaderCallback, setLineSeparator, setResource, setSaveState, setShouldDeleteIfEmpty, setShouldDeleteIfExists, setTransactional, update, writegetExecutionContextKey, getName, setExecutionContextName, setNamepublic JsonFileItemWriter(org.springframework.core.io.Resource resource,
JsonObjectMarshaller<T> jsonObjectMarshaller)
JsonFileItemWriter instance.resource - to write json data tojsonObjectMarshaller - used to marshal object into json representationpublic void afterPropertiesSet()
throws java.lang.Exception
java.lang.ExceptionInitializingBean.afterPropertiesSet()public void setJsonObjectMarshaller(JsonObjectMarshaller<T> jsonObjectMarshaller)
JsonObjectMarshaller to use to marshal object to json.jsonObjectMarshaller - the marshaller to usepublic java.lang.String doWrite(java.util.List<? extends T> items)
AbstractFileItemWriterdoWrite in class AbstractFileItemWriter<T>items - to be written