upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfiatjaf_ <fiatjaf@gmail.com>2023-12-29 18:15:21 -0300
committerGitHub <noreply@github.com>2023-12-29 18:15:21 -0300
commit000c51ef44c3ff1e0842139ada3859ba0a9b540f (patch)
treee6a73fc097c3dfadb597cb62ca6cea6cfca9e300
parent17c67ef5577c8ac5419a1081aadea57e30f8c133 (diff)
parentda19c078ab892b578a5c35968443205c9e8ac27f (diff)
Merge pull request #635 from nostr-protocol/clarify-json-serialization
Clarify JSON serialization for the `id` field
-rw-r--r--01.md14
1 files changed, 13 insertions, 1 deletions
diff --git a/01.md b/01.md
index ec872c3..ecac6f6 100644
--- a/01.md
+++ b/01.md
@@ -29,7 +29,7 @@ The only object type that exists is the `event`, which has the following format
29} 29}
30``` 30```
31 31
32To obtain the `event.id`, we `sha256` the serialized event. The serialization is done over the UTF-8 JSON-serialized string (with no white space or line breaks between the fields) of the following structure: 32To obtain the `event.id`, we `sha256` the serialized event. The serialization is done over the UTF-8 JSON-serialized string (which is described below) of the following structure:
33 33
34``` 34```
35[ 35[
@@ -42,6 +42,18 @@ To obtain the `event.id`, we `sha256` the serialized event. The serialization is
42] 42]
43``` 43```
44 44
45To prevent implementation differences from creating a different event ID for the same event, the following rules MUST be followed while serializing:
46- No whitespace, line breaks or other unnecessary formatting should be included in the output JSON.
47- No characters except the following should be escaped, and instead should be included verbatim:
48 - A line break, `0x0A`, as `\n`
49 - A double quote, `0x22`, as `\"`
50 - A backslash, `0x5C`, as `\\`
51 - A carriage return, `0x0D`, as `\r`
52 - A tab character, `0x09`, as `\t`
53 - A backspace, `0x08`, as `\b`
54 - A form feed, `0x0C`, as `\f`
55- UTF-8 should be used for encoding.
56
45### Tags 57### Tags
46 58
47Each tag is an array of strings of arbitrary size, with some conventions around them. Take a look at the example below: 59Each tag is an array of strings of arbitrary size, with some conventions around them. Take a look at the example below: