jackson-dataformats-text icon indicating copy to clipboard operation
jackson-dataformats-text copied to clipboard

Add FlowStyleResolver to enable custom YAML node style resolution

Open axpendix opened this issue 4 years ago • 7 comments

This adds a desired mechanism to specify YAML node styles (flow styles in snakeyaml) for individual object and array nodes, via implementing a FlowStyleResolver and checking the field names of given object or array nodes.

References: #185 #133 #43

axpendix avatar Feb 03 '21 22:02 axpendix

@axpendix Apologies for slow follow up here: will try to get this done soon now (hopefully today). Quick question: did I mention CLA earlier? If not, I'd need this:

https://github.com/FasterXML/jackson/blob/master/contributor-agreement.pdf

and after I get it, can merge. CLA only needs to be sent once so if this was already taken care of no need to re-send (I just need to locate it). If you do need to send it, the common way is to print, fill & sign, scan/photo, email to info at fasterxml dot com.

Looking forward to merging this!

cowtowncoder avatar Feb 18 '21 21:02 cowtowncoder

@pjfanning What do you think about this earlier PR? I don't think I have gotten a CLA to merge this, but I suppose that exposing more of SnakeYAML's functionality might make sense. Not sure how well it'd merge with snakeyaml-engine in 3.0 but otherwise.

cowtowncoder avatar Sep 24 '22 20:09 cowtowncoder

@cowtowncoder I haven't really messed about with these features of snakeyaml. The only reason I wanted to expose the LoaderOptions was because the default 3Mb limit for parsing is quite small.

pjfanning avatar Sep 24 '22 21:09 pjfanning

@pjfanning sure, understood. And changes here are bit more involved as the handler can change settings on per-property name basis, which should be tested etc.

cowtowncoder avatar Sep 25 '22 00:09 cowtowncoder

@cowtowncoder one thing we could do is to allow users to set their own DumperOptions on YAMLFactory (like they can now with LoaderOptions). If users provide their own non-null DumperOptions, then https://github.com/FasterXML/jackson-dataformats-text/blob/2.14/yaml/src/main/java/com/fasterxml/jackson/dataformat/yaml/YAMLGenerator.java#L294 will be skipped. Would this make sense as v2.14 change?

I've added https://github.com/FasterXML/jackson-dataformats-text/pull/345 to show how this might work. This new PR does not let you have different yaml flow styles depending on the element name though (like this PR 242 is about).

pjfanning avatar Sep 25 '22 10:09 pjfanning

@pjfanning I think that is a good starting point and probably covers many use cases even if not that particular one.

cowtowncoder avatar Sep 25 '22 20:09 cowtowncoder

@axpendix do you think that something can be improved in SnakeYAML to support it ? Is this similar ?

asomov avatar Jan 10 '23 18:01 asomov