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

Make JSON number serialization compatible with ES6 (and V8) #789

Open
cyberphone opened this issue Jan 21, 2016 · 6 comments
Open

Make JSON number serialization compatible with ES6 (and V8) #789

cyberphone opened this issue Jan 21, 2016 · 6 comments

Comments

@cyberphone
Copy link

After looking into the code it seems that numbers do not follow ES6.
This is usually not a problem but there's a new use-case which may motivate an update:

chakra-core/ChakraCore#149

Unfortunately this is an non-trivial thing:
https://github.com/cyberphone/openkeystore/blob/master/library/src/org/webpki/json/JSONObjectWriter.java#L147

@JamesNK
Copy link
Owner

JamesNK commented Jan 21, 2016

Neither of those links tell me anything. Where is the ES6 number specification? And give an example of a number that is wrong and what the correct number is.

@cyberphone
Copy link
Author

@JamesNK Here is the number specification:
7.1.12.1 in http://www.ecma-international.org/ecma-262/6.0/ECMA-262.pdf

I don't have a JSON.net example but double.toString() wasn't designed for ES6 compatibility so the difference in formatting is likely to be rather big.

 Double d = 0.00005;
 Console.Write(d);

The above returns 5E-05 while ES6 mandates 0.00005

@cyberphone
Copy link
Author

@JamesNK
Copy link
Owner

JamesNK commented Jan 25, 2016

I'll wait until MS fixes this in DCJS and then reuse it

https://github.com/dotnet/corefx/issues/5647

@cyberphone
Copy link
Author

@JamesNK Sounds like a reasonable solution. I just hope it won't take forever :-)

@cyberphone
Copy link
Author

Now it is available:
https://github.com/cyberphone/json-canonicalization/tree/master/dotnet/es6numberserialization

Finally making clear text signatures using Json.NET fully realistic!
https://github.com/cyberphone/json-canonicalization/tree/master/dotnet/json.net.sign#clear-text-signature-sample-solution

Unfortunately there is a bug in .NET with respect to parsing floating point numbers:
https://github.com/dotnet/coreclr/issues/17467

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

2 participants