-
-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add YAMLGenerator.Feature.INDENT_ARRAYS_WITH_INDICATOR
to indent by 2 spaces
#175
Comments
Ok so what is the specific problem? Is there functional problem (can not read resulting data back), or visual preference (would prefer output to look different)? |
Hi @cowtowncoder, I also found this behavior surprising and undesirable. I don't believe this causes any problems with correctness, it's just a style preference. For example, say we have the following yaml:
With the current behavior of
The desired behavior would be:
|
Ok that makes sense; I just want to make sure I understand the request: nothing wrong in preferences for output per se. |
@cowtowncoder please check if #227 suits you |
@dswiecki Thanks! Added one note on PR. One other thing: have I already asked for a CLA? If not, I'd need it (but just once, for the first contribution): https://github.com/FasterXML/jackson/blob/master/contributor-agreement.pdf and the easiest way is usually to print the doc, fill & sign, scan/photo, email to |
Hoping to get this still in 2.12, just waiting for CLA. There is still time, earliest possible release date would be early November. |
@cowtowncoder just bumped into this issue on my code too, 👍 But saw the CLA blocker :( what if the contributor doesn't want to (how can we unblock this) ? Plus, the CLA also requires personal information that many people might feel intrusive, especially when they are the ones "contributing". Maybe if there's some sort of automated disclaimer (first comment/description) for any new PRs submitted saying something like "By submitting your PR you hereby grant us bla bla bla" This was just my common sense, and I might be wrong, I just saw this as an unnecessary formality we all could benefit from dropping if that was possible. |
Sory for my delay, I'll try provide CLA and update PR today |
@IsmailMarmoush I do not ask for CLA because I find it personally useful but because it makes my life as maintainer easier -- it is something that has saved me from having to interact much with corporate lawyers. Bigger corporations are wary of OSS projects that do not require contribution attributions; I get contacts about this couple of times per year. But fortunately, so far getting CLA has rarely been even temporary blocker. @dswiecki Thank you! |
YAMLGenerator.Feature.INDENT_ARRAYS_WITH_INDICATOR
to indent by 2 spaces
I totally understand, thank you very much @cowtowncoder for your help and great efforts! |
Using a simple piece of code like below - the indentation of the array is only 1 space..
g.writeArrayFieldStart( "schemes" );
g.writeString( url.getProtocol().toLowerCase() );
g.writeEndArray();
Output is as such (bad formatting here - but only 1 space before the dash!):
schemes:
- http
Using 2.10.2 versions in my pom.xml
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>2.10.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.10.2</version>
</dependency>
YAMLGenerator created as such (tried different combos):
YAMLGenerator g =
new YAMLFactoryBuilder( new YAMLFactory() ).
configure( Feature.LITERAL_BLOCK_STYLE, true ).
configure( Feature.WRITE_DOC_START_MARKER, true ).
configure( Feature.INDENT_ARRAYS, true ).
build().createGenerator( new PrintWriter( bo ) );
g.disable(Feature.MINIMIZE_QUOTES);
The text was updated successfully, but these errors were encountered: