-
Notifications
You must be signed in to change notification settings - Fork 66
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
How do infinity and negative infinity serialize? #33
Comments
thats correct |
conjure-java does not implement this properly: @Test
public void double_nan_fields_should_be_serialized_as_a_string() throws Exception {
assertThat(mapper.writeValueAsString(DoubleExample.of(Double.NaN)))
.isEqualTo("{\"doubleValue\":\"NaN\"}");
}
|
The current wire format seems to contradict itself - in particular this doesn't hold for infinities:
|
I think we should ban Nan and infinity.
// mobile
…________________________________
From: Steven Fackler <[email protected]>
Sent: Thursday, July 5, 2018 4:53:42 PM
To: palantir/conjure
Cc: Subscribed
Subject: Re: [palantir/conjure] How do infinity and negative infinity serialize? (#33)
The current wire format seems to contradict itself - in particular this doesn't hold for infinities:
Every Conjure object (including primitives, complex objects, containers, etc.) is representable as a JSON object such that, intuitively, deserialize(serialize(object)) == object.
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub [github.com]<https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_palantir_conjure_issues_33-23issuecomment-2D402884436&d=DwMFaQ&c=izlc9mHr637UR4lpLEZLFFS3Vn2UXBrZ4tFb6oOnmz8&r=UfcWCaR4ui50AFap-gezrx5XYtPtH-9JpazU7tbRW-4&m=ttIXm1kEu86L8sgx82vREBnq7yiWu5qMinPfpWLf4_8&s=Z6uCxb0En8m23c-czMzUn75UFvLZEmJfFkm_bwJ4SK4&e=>, or mute the thread [github.com]<https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_notifications_unsubscribe-2Dauth_AGOdwc89zDnTIoqBnIKqq4ole6CxZtFXks5uDqcGgaJpZM4VBnsM&d=DwMFaQ&c=izlc9mHr637UR4lpLEZLFFS3Vn2UXBrZ4tFb6oOnmz8&r=UfcWCaR4ui50AFap-gezrx5XYtPtH-9JpazU7tbRW-4&m=ttIXm1kEu86L8sgx82vREBnq7yiWu5qMinPfpWLf4_8&s=m1fd0Yewa8se2SE8x802gESNK4fRFsc8iMmdXV-2E8g&e=>.
|
By making a |
Pretty sure we discussed this a month ago and the plan was to:
|
Yes, that ("does not support") is what I was advocating for above. |
I agree with @markelliot and @uschi2000 and would like to see this changed. The current behavior of typing doubles as |
@dphilipson I've tried to capture the tradeoffs of just banning these things in the Handling double NaN and Infinity RFC... we found that the assertion "nobody wants to define APIs which accept or produce NaN values" is not quite true, as there is a plausible use case for app which render customer data, which may itself contain NaN/Infinity. If your specific feedback is focussed on the typescript ergonomics of doubles then I think there's a typescript specific solution which is to introduce a serialization/deserialization layer so that the JSON string "NaN" received from the wire is translated into the JavaScript EDIT - I've opened palantir/conjure-typescript#48 to describe this proposal in more detail. |
The spec indicates that doubles serialize as
number | "NaN"
- would infinities be treated asNaN
then?The text was updated successfully, but these errors were encountered: