-
Notifications
You must be signed in to change notification settings - Fork 577
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
NIP-01 suggests encoding "content" in a non-JSON compatible way #1403
Comments
As I recall the intent was that those characters are invalid nostr characters, so we don't need encodings for them. |
Unicode escape codes are an aberration from a distant past that should be forgotten. As long as you're not doing anything super weird this problem won't happen and most default JSON encoders will do the right thing. |
After looking into this, there's more than just I think to prevent headache for someone who decides to implement their own JSON (de)serializer, NIP-01 could:
As much as I would like the ability to send raw control codes, given that terminals are very much not "a distant past". I do think that option 1 is more ideal so that the string values are ensured to be valid utf-8, making compliant parsing easy for both |
Very good points. I agree. |
The base protocol (
NIP-01
) draft currently says this:It says "all other characters must be included verbatim", but the JSON standard (see Section 9 "String") requires that "the control characters U+0000 to U+001F" are escaped using
\uXXXX
unicode escapes.An example of a
"content"
value that is valid in NIP-01 but invalid in JSON:At this point it's probably not feasible to change the draft to use valid JSON, but the draft should probably mention that you must deviate from the JSON standard to produce NIP-01 compliant event IDs.
The text was updated successfully, but these errors were encountered: