> --
> You received this message because you are subscribed to the Google Groups "SnakeYAML" group.
> To post to this group, send email to snakeya...@googlegroups.com.
> To unsubscribe from this group, send email to snakeyaml-cor...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/snakeyaml-core?hl=en.
>
def dumperOptions = new DumperOptions() {
@Override
DumperOptions.ScalarStyle calculateScalarStyle(ScalarAnalysis
analysis, DumperOptions.ScalarStyle style) {
analysis.multiline ? DumperOptions.ScalarStyle.LITERAL : style
}
}
This is working for 2 / 3 of my samples but one (JSON data) is still
using quoted style.
I notice that the calculateScalarStyle method is deprecated now. Am I
using the right approach or is there a better way to handle it?
Thanks,
Rob
-
Andrey
In the example I'm using (the YAML output I'm getting is here:
https://github.com/robfletcher/betamax/blob/master/src/test/resources/betamax/tapes/smoke_spec.yaml).
Without specifying DumperOptions at all then I get either double or
single quoted style for large scalar values. The plain style used for
the short values is perfect. If at all possible I'd like to be able to
somehow force the use of the literal style for the 'body' property as
this would be easier for people to edit manually. The code used to
generate it is reasonably complex. An HTTP request goes via a proxy
which serializes the response as YAML. The HTTP response data is
passed verbatim to SnakeYAML.
This is an end-to-end smoke test not a unit level test. I haven't
tested specific output at the unit level just whether the YAML
serialization / deserialization is working (which it is, perfectly).
Java platform.\">\t\n\t\n <title>Grails
</a>\t\t\t\n\t</div>\n\n\t<div id=\"springSourceLogo
</a>\t\t\t\t\t\t\t\t\n \n </h3>\n
With tabs the YAML document can easily go out of the control. Avoid tabs. Can you may be transform all the tabs to spaces on the fly ?
When you remove all the tabs, the YAML document shall be dumped with the block literal style.
-AndreyI understand that the style is chosen automatically based on the
content but what I was asking is whether, in a case where more than
one style would be a valid option, I can select the one to use on a
property-by-property basis. It seems like this is not possible.
I can override calculateScalarStyle but since I can't tell from there
what property is being emitted I can only use a heuristic such as
whether the data is multiline or longer than x. Also since that method
is deprecated I guess at some point this technique will stop working
for me altogether.
Thanks for all the help.
> --
> You received this message because you are subscribed to the Google Groups
> "SnakeYAML" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/snakeyaml-core/-/-KlWcpa-OmsJ.