fraction / ssb-validation-dataset

3 stars 0 forks source link

Invalid JSON numbers #1

Open christianbundy opened 4 years ago

christianbundy commented 4 years ago

It would be great to add a message that's valid except that it violates Number.toString(). For example:

{
  "timestamp": 1e1
}

I'm reasonably sure that this is valid JSON, but validators like SSB-Validate always re-encode with JSON.stringify() before checking the signature, and that would result in:

{
  "timestamp": 10
}

I think we can safely use a number on integers where -1e21 < x < 1e21, and use scientific notation outside of that, but I don't remember how this works with decimals. Something something "20 decimal digits" something something? :shrug:

christianbundy commented 4 years ago

In other words, I'd love to add two tests:

christianbundy commented 4 years ago

Actually, writing invalid JSON might be unwise, since this repository is supposed to have valid JSON only. Maybe just the first test is necessary, and the second test can be checked by some JSON parsing dataset.

christianbundy commented 4 years ago

https://www.ecma-international.org/ecma-262/6.0/#sec-tostring-applied-to-the-number-type