News for hackers. Stuff that matters.
Re:JSON Schema Store by peoplefromibiza on Monday August 21, 2023 @04:54AM (#37206938)
> JSON just says do “\0” and calls it a day

nope

   jq "." <<< "\0"
   parse error: Invalid numeric literal at line 2, column 0

   jq "." <<< '{"name": "\0"}'
   parse error: Invalid escape at line 1, column 13
maybe you mean null, which has a lot of different issues though.

   jq "." <<< "null"          
   null

   jq "." <<< '{"name": null}'
   {
     "name": null
   }
Re:JSON Schema Store by maskros on Monday August 21, 2023 @08:42AM (#37208735)
"\0" is not a valid JSON string escape sequence.

However, "\u0000" is.

Re:JSON Schema Store by peoplefromibiza on Monday August 21, 2023 @10:19AM (#37209900)
not according to jq or firefox

   >> JSON.parse("\u0000")
   Uncaught SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
       <anonymous> debugger eval code:1
at that point "null" looks like a better more compatible option.
Re:JSON Schema Store by unilynx on Monday August 21, 2023 @01:03PM (#37212303)
they're not comparable at all. you can't embed a null into a string

\u0000 works fine with firefox with the proper syntax

  JSON.parse(`"\\u0000"`)
  "\u0000"
and jq supports it too

  printf '{"null":"\u0000"}' | jq
  {
    "null": "\u0000"
  }
Re:JSON Schema Store by peoplefromibiza on Monday August 21, 2023 @01:52PM (#37212980)
> the proper syntax

of course! I forgot to quote those quotes! (facepalm)

that works. and uses a single byte too.

TIL.