PrettyPrinter Indenter: Ability to insert eol before object and array entries
See original GitHub issueI’d like to be able to configure an indenter to insert a newline before object and array braces/brackets. Instead of:
{
foo: {
bar: true
}
}
I want:
{
foo:
{
bar: true
}
}
Issue Analytics
- State:
- Created 9 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Jackson JSON Deserialization: array elements in each line
I am using Jackson and would like to pretty-print JSON such that each element in arrays goes to each line ...
Read more >PrettyPrinter (Jackson-core 2.6.0 API) - FasterXML
Interface for objects that implement pretty printer functionality, such as indentation. Pretty printers are used to add white space in output JSON content, ......
Read more >IO tools (text, CSV, HDF5, …) — pandas 1.5.2 documentation
The Python engine loads the data first before deciding which columns to drop. ... string values from the columns defined by parse_dates into...
Read more >How to Prettify Data Structures with Pretty Print in Python
The dictionary is now an array. The next step is printing the contents using print().
Read more >Groovy Language Documentation
You will notice that the resulting string contains a newline character as first ... Groovy classes must specify their package before the class...
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 FreeTop 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
Top GitHub Comments
No, this will not work and is not intended to work. Indenter is valid within context of an open
JsonGenerator
, and one will be constructed for eachwriteValueAsString
.ObjectWriter
s are stateless, immutable, and there is no way (or intent) to share state of indenter.To produce root value separators, a single
JsonGenerator
must be used, as that tracks output state, to know where and when to add root value separator.I think the problem is that
ObjectWriter.writeValueAsString()
creates a nested writer per invocation, sorootValueSeparator
is never triggered (it only sees us writing a single value each time). To clarify: I need a way to “clean up” the pretty printer at the beginning or end of eachwriteValueAsString()
invocation. I don’t see a way to do that with the current API.