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
To Add an ES6 Compatible Way to ToString double #16471
Comments
This would be useful for Json.NET or any other JavaScript/JSON focused .NET library. |
We would need a formal API proposal for this. |
if there is any change in the API surface then it will be good if include the proposal of the changes here. |
Although the spec has not yet been published, Microsoft is (as shown in the document below), actively participating in a standardization effort building on ES6-compatible JSON processing: |
Now the Microsoft sponsored proposal is published: https://tools.ietf.org/id/draft-erdtman-jose-cleartext-jws-00.html
|
This is partially resolved by dotnet/coreclr#22040.
This will now be supported by using
We will now return the "shortest roundtrippable string":
This would require additional changes to the |
@tannergooding If you feel uncomfortable changing NumberToString to support the serialization required by https://tools.ietf.org/html/draft-rundgren-json-canonicalization-scheme-02 that's OK because I have already solved this by a V8-inspired port to .NET. However, I have just found a better base in the form of "Ryu" (https://github.com/ulfjack/ryu) which shrinks the code to almost nothing and is very fast as well. |
I think it is something that is reasonable to expose. Although I am unsure if the right thing is to have a new format specifier, a new API, or if we should just fix the existing My initial thoughts are that just fixing the existing
https://github.com/dotnet/coreclr/issues/19596 is tracking further investigation into the
|
@cyberphone, it might be worth noting that, while steps 6-10 look to be doable (it looks like step 8 is one where we are comparing The ES6 specification looks to specify that
|
CC. @danmosemsft as an FYI to the above request. A summary is that they would like us to either modify our existing NumberToString implementation (or provide some other mechanism to get the desired functionality) to be compatible with the ES6 specification. This would basically involve just tweaking some of the boundaries we are checking that determines when we print using the |
The ES6 spec for JSON number serialization is indeed a bit deviating from the IEEE spec but in a transport format it does in my opinion not make (too) much sense sending "-0", That is, if I were to update Java version based on Ryu: |
Tagging subscribers to this area: @tannergooding |
An RFC building on this scheme will be published in the coming weeks: |
DataContractJsonSerializer converts a double value to a string by calling,
The string is not compatible with ECMAScript 6 (see the specs). For example,
An ES6 compatible way to ToString double and floats would be useful.
The text was updated successfully, but these errors were encountered: