"i=
n accordance with ... assq and plist-get" (plist-get also uses the fir=
st element)
+Note that @code{nil} is both a v=
alid alist and a valid plist and
+represents the empty JSON objec=
t, @code{@{@}}, not @code{null},
+@code{false}, or an empty array=
, all of which are different JSON
+values.
=
div>
This is a bit hard to parse, could you split it up into multiple s=
entences?
=C2=A0or @code{plist} to use plists=
with keyword
+symbols as keys.
It=
's merely a somewhat common convention to use keywords (starting with :=
) in plist keys. I think it's better to just use the same symbols, i.e.=
neither add nor strip colons. That would also make the implementation simp=
ler.
You should also mention how the function dist=
inguishes between alists and plists.
+=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 /* If using plists, maybe strip the ":&quo=
t; from symbol-name */
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (is=
_plist &&
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 ':' =3D=3D key_str[0] &&
+=C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 key_str[1] ) key_str =3D &key_str[1];=
div>
As said above, I think it's better to rem=
ove this code (and maybe document that colons aren't stripped). Especia=
lly the "maybe" part makes the interface more complex and subtle.=
For example, a caller sees that (a 1 b 2) gets serialized to {"a"=
;: 1, "b": 2} and then might reasonably conclude that (a 1 :a 2) =
gets serialized to {"a": 1, ":a": 2}, but that would be=
wrong. It's more obvious and easier to understand to not treat colons =
specially.
+Vectors will be converted to JSON arra=
ys, and hashtables and alists to
+JSON objects.=C2=A0=C2=A0
=
Mention plists. (MIght be better to split this up into =
two sentences, and/or switch to active voice.)
+=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 char *key=
word_key_str =3D SAFE_ALLOCA (1 + strlen(key_str) + 1);
+=C2=A0 =
=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 keyword_key_str[0]=
=3D':';
Again, no special treatment =
for colons please.
+see.=C2=A0 The returned o=
bject will be a vector, hashtable, alist, or
+plist.=C2=A0 Its el=
ements will be `:null', `:false', t, numbers, strings,
<=
div>
Nit: you're using Oxford commas inconsistently. I=
9;m fine either way, but please stay consistent.
<=
div>+=C2=A0 (should-error (json-serialize '#1=3D(:a 1 . #1#)) :type =
9;circular-list)