-
-
Notifications
You must be signed in to change notification settings - Fork 149
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
MINIMIZE_QUOTES Question #247
Comments
I tried but then get an error because YAMLGenerator doesn't recognize that as a valid value for some reason |
definitely seems related to the
and it output
|
I know ! is considered a custom type in YAML, which is how we are using it (hence its getTypeID() and specified as a JsonTypeName using the decorator. but the requirement is to have the type and its ID (getID()) on the same line. |
As of Jackson 2.12, definition of what must be quoted is handled by I'll quickly verify this locally to make sure. |
Yup. Jackson yaml module tries to output as "plain", does not consider So your question is not about MINIMIZE_QUOTES as much as type id? Usually with Jackson this should be done by forcing type Id, but that may be tricky for type |
Yeah, it makes sense after documenting a little more. What am I missing here? I'm trying to basically get it to write the type Id without quotes, and then this field within the object. I can get it to do the field, but seem to be missing some way for yaml generator to know I need it to write the type ID, I think. |
Jackson writes type ids based on
to indicate that YAML's tag system is to be used instead of otherwise default Jackson use of separate property. But a custom serializer could be written to make it bit simpler. It'd do something like:
and add annotation to indicate its use for the field in question (or for custom type if you use something other than I have not tested this, but conceptually this should work. And if you do have time to play with it against 2.12.2, I would be interested in resolving issues if there are any (since it's not tested I am guessing there's a good chance there could be edge cases). This seems like something that definitely should be possible: and at least first if a custom serializer approach worked, that'd be a good start I think? |
we are using polymorphic type, and have set @jsontypeInfo on the class that is being passed our custom serializer. I enabled that feature you mentioned on the YAMLGenerator, but am getting
where RoleCustomSerializer is doing
and role is a polymorphic type with
I also tried
Where getTypeID() returns a string field that is annotated |
@mkkeffeler Ok. I would be interested in a code snippet, or test case: this sounds like something I could/should improve upon. I assume this is with 2.12.2? |
would love to show you real fast as well, its possible im doing something just slightly different. but yes, I upgraded from 2.12.1 to 2.12.2, same issue. |
Can someone help me understand why I get that error? "com.fasterxml.jackson.core.JsonGenerationException: No native support for writing Type Ids"? According to the function that checks |
@mkkeffeler If you can give a basic reproduction, I can have a look. Factory should pass relevant settings to generator, yes; just make sure your |
So remember I said this.
The error was that the generator didn't recognize that as a valid way to start an object. So, I found this
Which writes the type of the object out, AND tells the generator that this is a START_OBJECT identifier. This ended up being one way I worked around the above issue. |
Using MINIMIZE QUOTES with a custom serializer for YAML. I try this in the custom serializer
which outputs
But then, if I add this
I get
I need this to get output without quotes, am I missing something with how I pass these characters in? I read online about special characters causing this, can I serialize these in some way maybe to fix that issue?
The text was updated successfully, but these errors were encountered: