mirror of
https://github.com/matrix-org/matrix-spec
synced 2026-02-12 00:53:43 +01:00
Cope with negative-zero, and give an example of negative-zero and a large power of ten (#1573)
This commit is contained in:
parent
414cc1ea52
commit
e9acece3ec
1
changelogs/appendices/newsfragments/1573.clarification
Normal file
1
changelogs/appendices/newsfragments/1573.clarification
Normal file
|
|
@ -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
|
||||||
|
|
@ -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
|
We define this encoding for a value to be the shortest
|
||||||
UTF-8 JSON encoding with dictionary keys lexicographically sorted by
|
UTF-8 JSON encoding with dictionary keys lexicographically sorted by
|
||||||
Unicode codepoint. Numbers in the JSON must be integers in the range
|
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
|
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
|
and JSON received from the network is likely to be already encoded using
|
||||||
|
|
@ -304,6 +305,21 @@ The following canonical JSON should be produced:
|
||||||
{"a":null}
|
{"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
|
### Signing Details
|
||||||
|
|
||||||
JSON is signed by encoding the JSON object without `signatures` or keys
|
JSON is signed by encoding the JSON object without `signatures` or keys
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue