question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`SequenceWriter` does not create multiple docs in a single yaml file

See original GitHub issue

Hi, 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:closed
  • Created 4 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
cowtowncodercommented, Dec 13, 2019

@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.

1reaction
cowtowncodercommented, Dec 12, 2019

init() is not meant to be called by anything other than ObjectWriter… I’ll add Javadoc stating that. So that should not be work around.

But I think the real problem is that YAMLGenerator.close() emits both DocumentEnd and StreamEnd events (or perhaps that DocumentEnd is NOT called at close of root-level Object or Array?).

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found