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

Cope with negative-zero, and give an example of negative-zero and a large power of ten #1573

Merged
merged 3 commits into from
Jul 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelogs/appendices/newsfragments/1573.clarification
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Clarify spec re canonical JSON to handle negative-zero; also, give an example of negative-zero and a large power of ten
18 changes: 17 additions & 1 deletion content/appendices.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,8 @@ To ensure that all implementations use the same JSON encoding we define
We define this encoding for a value to be the shortest
UTF-8 JSON encoding with dictionary keys lexicographically sorted by
Unicode codepoint. Numbers in the JSON must be integers in the range
`[-(2**53)+1, (2**53)-1]`.
`[-(2**53)+1, (2**53)-1]`, represented without exponents or decimal
places, and negative zero `-0` MUST NOT appear.

We pick UTF-8 as the encoding as it should be available to all platforms
and JSON received from the network is likely to be already encoded using
Expand Down Expand Up @@ -304,6 +305,21 @@ The following canonical JSON should be produced:
{"a":null}
```

Given the following JSON object:

```json
{
"a": -0,
"b": 1e10
}
```

The following canonical JSON should be produced:

```json
{"a":0,"b":10000000000}
```

### Signing Details

JSON is signed by encoding the JSON object without `signatures` or keys
Expand Down