`SequenceWriter` does not create multiple docs in a single yaml file
See original GitHub issueHi,
I am trying to use SequenceWriter
as suggested here to serial objects to multidocs but unsuccessful in doing do. Here is my code :
File directory = new File("src/main/resources/output");
String fileName = "output-multidocs.yaml";
try(SequenceWriter sequenceWriter = mapper.writer().writeValues(new File(directory, fileName))){
sequenceWriter.init(true);
sequenceWriter.writeAll(detailsList); // detailsList is an arrayList of object.
sequenceWriter.writeAll(detailsList); // Expectation is this would create separate doc in the same yaml file. But it was appending to above list.
}catch (Exception e){
e.printStackTrace();
}
Could you please advice me the way to serialize objects into multidocs in a single yaml file.
Issue Analytics
- State:
- Created 4 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Deserialize POJOs from multiple YAML documents in a ...
I'd like to use Jackson to deserialize all documents from the file, but I don't see a way to use a normal ObjectMapper...
Read more >SequenceWriter (jackson-databind 2.6.0 API) - FasterXML
Writer class similar to ObjectWriter , except that it can be used for writing sequences of values, not just a single value. The...
Read more >Line-delimited JSON with Jackson - cowtowncoder - Medium
YAML ( jackson-dataformat-yaml ): single physical file or stream may contain multiple documents so the same approach should work as well; Avro ( ......
Read more >Using Oracle GoldenGate Capture for Cassandra
The Oracle GoldenGate capture (Extract) for Cassandra is used to get changes from Apache Cassandra databases.
Read more >Kafka Connect FileSystem Connector 1.3 documentation
Files with Avro format can be read with this reader. The Avro schema is not needed due to is read from the file....
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@sishbi I think it should be released before end of the year, depending on when I have time to cut full minor release. So probably in 2 weeks or so.
init()
is not meant to be called by anything other thanObjectWriter
… I’ll add Javadoc stating that. So that should not be work around.But I think the real problem is that
YAMLGenerator.close()
emits bothDocumentEnd
andStreamEnd
events (or perhaps thatDocumentEnd
is NOT called at close of root-level Object or Array?).