From: Eli Zaretskii <eliz@gnu.org>
To: "João Távora" <joaotavora@gmail.com>
Cc: emacs-devel@gnu.org
Subject: Re: [PATCH] Accept plists when serializing and parsing JSON
Date: Fri, 01 Jun 2018 12:39:38 +0300 [thread overview]
Message-ID: <83o9gug811.fsf@gnu.org> (raw)
In-Reply-To: <87sh6awls5.fsf@gmail.com> (message from João Távora on Tue, 29 May 2018 15:59:06 +0100)
> From: João Távora <joaotavora@gmail.com>
> Date: Tue, 29 May 2018 15:59:06 +0100
>
> So I found this other thread
>
> https://lists.gnu.org/archive/html/emacs-devel/2017-12/msg00667.html
>
> where plist support for json.c is briefly requested and discussed, but
> there didn't seem to be an overwhelming argument against it, so I had
> another look at the file and it didn't seem very hard or problematic to
> implement.
>
> Anyway, I had a go.
Thanks, please see a few comments below.
> +@vindex json-serialize-use-plists
> +@cindex serializing plists as json
> + For the serialization function, the variable
> +@var{json-serialize-use-plists} controls the converse process,
json-serialize-use-plists is the literal name of a variable, so it
should have the @code markup, not @var.
> +resolving the ambiguity when a list is found in the Lisp object to
> +serialize. If @code{nil}, its default, the list is interpreted as an
^^
Two spaces between sentences, please.
> + if ( EQ (Vjson_serialize_use_plists, Qt) ) {
> + key_symbol = XCAR (tail);
> + tail = XCDR(tail);
> + CHECK_CONS (tail);
> + value = XCAR (tail);
> + if (EQ (tail, li.tortoise)) circular_list (lisp);
> + } else {
> + Lisp_Object pair = XCAR (tail);
Our style is to write
if (something)
{
then-part;
}
else
{
else-part;
}
Also, please don't leav any whitespace between the opening parenthesis
and the following character, and similarly with closing parens. IOW,
this:
if ( EQ (Vjson_serialize_use_plists, Qt) )
should be this instead:
if (EQ (Vjson_serialize_use_plists, Qt))
> + json_object_foreach (json, key_str, value)
> + {
> + /* No idea if using AUTO_STRING and Fconcat for
> + making keywords is idiomatic, but seems to work
> + nicely */
> + AUTO_STRING (colon, ":");
> + Lisp_Object key =
> + Fintern (CALLN (Fconcat, colon, json_build_string (key_str))
> + , Qnil);
> + result = Fcons (key, result); /* build the plist as
> + value-key since
> + we're going to
> + reverse it in the
> + end.*/
> + result = Fcons (json_to_lisp (value, object_type), result);
> + }
Here I'd use intern_1 instead, it would allow you to avoid
unnecessarily consing Lisp objects. (Yes, I realize that the same
comment applies to the existing code.)
> + /* If non-nil use plists instead of alists in json-serialize.*/);
^
Comma is missing there.
next prev parent reply other threads:[~2018-06-01 9:39 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-29 14:59 [PATCH] Accept plists when serializing and parsing JSON João Távora
2018-05-29 21:20 ` Philipp Stephani
2018-05-29 22:03 ` João Távora
2018-05-30 6:37 ` Yuri Khan
2018-05-30 8:58 ` João Távora
2018-06-02 8:04 ` Philipp Stephani
2018-06-03 0:34 ` João Távora
2018-06-03 4:05 ` Stefan Monnier
2018-06-03 13:43 ` João Távora
2018-06-02 7:45 ` Philipp Stephani
2018-06-02 7:39 ` Philipp Stephani
2018-06-01 9:39 ` Eli Zaretskii [this message]
2018-06-01 23:29 ` João Távora
2018-06-02 6:55 ` Eli Zaretskii
2018-06-02 8:24 ` Philipp Stephani
2018-06-02 9:00 ` Eli Zaretskii
2018-06-02 16:46 ` Philipp Stephani
2018-06-02 19:18 ` Eli Zaretskii
2018-06-08 14:45 ` Eli Zaretskii
2018-06-02 8:30 ` Philipp Stephani
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=83o9gug811.fsf@gnu.org \
--to=eliz@gnu.org \
--cc=emacs-devel@gnu.org \
--cc=joaotavora@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).