-
-
Notifications
You must be signed in to change notification settings - Fork 150
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
Questionable parsing/serialising of YAML ordered maps #340
Comments
Hi @dpetroff! Right, this because type Unfortunately I am not sure if this can even be handled, as streaming parser/generator do not have concept of structured types -- they operate on token streams, and actual Object binding operation is handled at format-agnostic databind layer. It seems that there are at least 2 aspects here, too, reading (deserialization) and writing (serialization). Both seem challenging to support. I do have one question on this, however:
I am not quite sure how the structure would change here? Jackson defaults to using |
A single-property object was not the best example. The parser seems to treat So rather than parsing the |
Hmmmh. It is odd, then, that SnakeYAML doesn't seem to do the translation to such a structure at token level. |
Ordered maps were introduced in YAML 1.1 and the spec discourages considering key order to be significant otherwise:
With jackson 2.13.3, this is parsed as a
Map<Object, List<Map>>
while I had expected it to be parsed as aMap<Object, LinkedHashMap>
instead. Besides being a bit odd and unexpected, serialising the parsed object producesNotice the missing
!!omap
in the output.I don't know how I would want to explicitly request
!!omap
serialisation - I'm certainly not suggesting clobbering the key parse order withHashMap
when!!omap
was not explicitly specified just so thatLinkedHashMap
suddenly means!!omap
, even though that approach would technically be compliant with the spec. Perhaps a configuration flag to select YAML 1.0 or YAML 1.1+ serialisation ofLinkedHashMap
would make sense? And maybe wrapper/delegate map objects to explicitly override the!!omap
type for a specificLinkedHashMap
instance regardless of the flag?The text was updated successfully, but these errors were encountered: