all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Eli Zaretskii <eliz@gnu.org>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: mail@xuchunyang.me, 32793@debbugs.gnu.org
Subject: bug#32793: 27.0.50; json-parse-string doesn't have the equivalent of json.el's json-array-type
Date: Fri, 12 Apr 2019 18:26:03 +0300	[thread overview]
Message-ID: <83zhovkzxw.fsf@gnu.org> (raw)
In-Reply-To: <b8c8cb88-ed10-e046-7ce3-b9b6758723ac@yandex.ru> (message from Dmitry Gutov on Fri, 12 Apr 2019 18:02:22 +0300)

> Cc: mail@xuchunyang.me, 32793@debbugs.gnu.org
> From: Dmitry Gutov <dgutov@yandex.ru>
> Date: Fri, 12 Apr 2019 18:02:22 +0300
> 
> > Come to think of this: why do we need this boolean at all?  The
> > callers which don't want :object-type parsed will ignore the result
> > anyway, so it sounds like something we could just toss.
> 
> I'd rather we didn't accept argument we cannot handle, to avoid false 
> expectations.
> 
> For example with this patch we can parse a JSON array into a Lisp list.
> 
> But there's no way to serialize a list back into a JSON array, yet.

This argument is meaningless for serializing, I think.  But OK.

> >> +              for (ptrdiff_t i = 0; i < size; ++i)
> >> +                result = Fcons (json_to_lisp (json_array_get (json, i), conf),
> >> +                                result);
> >> +              result = Fnreverse (result);
> > 
> > If you cons the list back to front, you can avoid the Fnreverse call,
> > which will make this faster.
> 
> Done. No real performance impact that I can see, but it didn't hurt either.

You just didn't try an array big enough for this to matter.

> > Also, please insert a call to rarely_quit into the loop, as JSON
> > vectors could be quite large, AFAIU.
> 
> Also done. In the json_array_array case as well, where it was missing, 
> it seems.

I don't mind, although in that case the loop just assigns value to a
vector that was already consed.

> json-parse-buffer and NEWS don't need updating, I think.

They don't?  Why not?

> Otherwise, done, see the new patch.

LGTM, with the above question, and this one gotcha:

> @@ -918,6 +961,9 @@ a list of keyword/argument pairs:
>  The keyword argument `:object-type' specifies which Lisp type is used
>  to represent objects; it can be `hash-table', `alist' or `plist'.
>  
> +The keyword argument `:array-type' specifies which Lisp type is used
> +to represent arrays; it can be `array' or `list'.

Please say here that 'array' is the default.

Thanks.





  reply	other threads:[~2019-04-12 15:26 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-21 12:56 bug#32793: 27.0.50; json-parse-string doesn't have the equivalent of json.el's json-array-type Xu Chunyang
2019-04-11 16:26 ` Dmitry Gutov
2019-04-11 16:46   ` Eli Zaretskii
2019-04-12  0:34     ` Dmitry Gutov
2019-04-12  9:22       ` Eli Zaretskii
2019-04-12 15:02         ` Dmitry Gutov
2019-04-12 15:26           ` Eli Zaretskii [this message]
2019-04-12 15:45             ` Dmitry Gutov
2019-04-12 17:42               ` Eli Zaretskii
2019-04-12 22:36                 ` Dmitry Gutov

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

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83zhovkzxw.fsf@gnu.org \
    --to=eliz@gnu.org \
    --cc=32793@debbugs.gnu.org \
    --cc=dgutov@yandex.ru \
    --cc=mail@xuchunyang.me \
    /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 external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.