Skip to content
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

Type id not provided on Double.NaN, Infinity with @JsonTypeInfo #2236

Closed
C-B-B opened this issue Jan 25, 2019 · 3 comments
Closed

Type id not provided on Double.NaN, Infinity with @JsonTypeInfo #2236

C-B-B opened this issue Jan 25, 2019 · 3 comments
Milestone

Comments

@C-B-B
Copy link

C-B-B commented Jan 25, 2019

When using polymorphic serialisation with @JsonTypeInfo, e.g. on a Collection of Objects, the type information is sent with the values to ensure correct deserialisation. Doubles (and others like Strings) don't get their types included given they are considered the default deserialisation type. This causes problems for Double.NaN, Double.POSITIVE_INFINITY and Double.NEGATIVE_INFINITY as they get deserialised into strings rather than Double.

Would it make sense to include the type for these three Double values to ensure they can also be correctly deserialised (I tested that the deserialisation works correctly if the type is included in the data)?

(Using 2.9.8)

Thanks!
CBB

@cowtowncoder
Copy link
Member

cowtowncoder commented Jan 27, 2019

Interesting edge case. Yes, that would indeed make sense.
Thank you for reporting the issue.

My main concern (without looking at code yet) is whether output as String is handled by serializer (if so, easy), or low-level JsonGenerator -- latter case would be difficult to handle cleanly wrt separation of responsibilities.

@cowtowncoder cowtowncoder changed the title Type not provided on Double NaN and Infinity with @JsonTypeInfo Type id not provided on Double.NaN, Infinity with @JsonTypeInfo Feb 9, 2019
@cowtowncoder cowtowncoder added 2.10 and removed 2.9 labels Feb 9, 2019
@cowtowncoder cowtowncoder added this to the 2.10.0 milestone Feb 9, 2019
@antoinetran
Copy link

Hi @cowtowncoder , is-it possible to have the same fix related to Float? Or is-it already working? Thank you!

@antoinetran
Copy link

Oh, I can see that this is already fixed for float, I believe.
I use

	<dependency>
		<groupId>com.fasterxml.jackson.core</groupId>
		<artifactId>jackson-databind</artifactId>
		<version>2.9.8</version>
	</dependency>

and Float.NaN gets serialized as:
["[[F",[["[F",["NaN"
and gets deserialized as Float.NaN, so this is good. I should try with Double later.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants