GNU bug report logs - #41946
27.0.91; native json parsing: add :empty-object configuration

Previous Next

Package: emacs;

Reported by: Ivan Yonchovski <yyoncho <at> gmail.com>

Date: Fri, 19 Jun 2020 05:54:02 UTC

Severity: wishlist

Tags: moreinfo, wontfix

Found in version 27.0.91

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 41946 in the body.
You can then email your comments to 41946 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#41946; Package emacs. (Fri, 19 Jun 2020 05:54:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Ivan Yonchovski <yyoncho <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 19 Jun 2020 05:54:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Ivan Yonchovski <yyoncho <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 27.0.91; native json parsing: add :empty-object configuration
Date: Fri, 19 Jun 2020 08:52:57 +0300
This is similar to :null-object/:false-object flags in
json-parse-string and solves the same issue - inability to distinguish
json's null from {}.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41946; Package emacs. (Fri, 19 Jun 2020 07:31:01 GMT) Full text and rfc822 format available.

Message #8 received at 41946 <at> debbugs.gnu.org (full text, mbox):

From: Eli Zaretskii <eliz <at> gnu.org>
To: Ivan Yonchovski <yyoncho <at> gmail.com>
Cc: 41946 <at> debbugs.gnu.org
Subject: Re: bug#41946: 27.0.91;
 native json parsing: add :empty-object configuration
Date: Fri, 19 Jun 2020 10:29:50 +0300
> From: Ivan Yonchovski <yyoncho <at> gmail.com>
> Date: Fri, 19 Jun 2020 08:52:57 +0300
> 
> 
> This is similar to :null-object/:false-object flags in
> json-parse-string and solves the same issue - inability to distinguish
> json's null from {}.

I don't think I understand the request.  Can you post more details,
please?  (Maybe it's some standard JSON feature that I'm not familiar
with?)




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41946; Package emacs. (Fri, 19 Jun 2020 08:08:02 GMT) Full text and rfc822 format available.

Message #11 received at 41946 <at> debbugs.gnu.org (full text, mbox):

From: yyoncho <yyoncho <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 41946 <at> debbugs.gnu.org
Subject: Re: bug#41946: 27.0.91;
 native json parsing: add :empty-object configuration
Date: Fri, 19 Jun 2020 11:07:27 +0300
[Message part 1 (text/plain, inline)]
Sorry, for the short description. Here it is what I can do now:

(json-parse-string  "{\"a\":null}"
                    :object-type 'plist
                    :null-object :null-object)
=> (:a :null-object)

Here it is what I want to be able to do also:

(json-parse-string  "{\"a\":{}}"
                    :object-type 'plist
                    :empty-object :empty)
=> (:a :empty)

The purpose of this flag is to be able to distinguish json's null from
json's empty object.
ATM this could be achieved only by binding null. I want to be able to bind
an empty object as well.

Thanks,
Ivan

On Fri, Jun 19, 2020 at 10:30 AM Eli Zaretskii <eliz <at> gnu.org> wrote:

> > From: Ivan Yonchovski <yyoncho <at> gmail.com>
> > Date: Fri, 19 Jun 2020 08:52:57 +0300
> >
> >
> > This is similar to :null-object/:false-object flags in
> > json-parse-string and solves the same issue - inability to distinguish
> > json's null from {}.
>
> I don't think I understand the request.  Can you post more details,
> please?  (Maybe it's some standard JSON feature that I'm not familiar
> with?)
>
[Message part 2 (text/html, inline)]

Severity set to 'wishlist' from 'normal' Request was from Stefan Kangas <stefan <at> marxist.se> to control <at> debbugs.gnu.org. (Sun, 18 Oct 2020 11:54:03 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41946; Package emacs. (Sat, 31 Jul 2021 15:08:02 GMT) Full text and rfc822 format available.

Message #16 received at 41946 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: yyoncho <yyoncho <at> gmail.com>
Cc: Philipp Stephani <phst <at> google.com>, Eli Zaretskii <eliz <at> gnu.org>,
 41946 <at> debbugs.gnu.org
Subject: Re: bug#41946: 27.0.91; native json parsing: add :empty-object
 configuration
Date: Sat, 31 Jul 2021 17:07:01 +0200
yyoncho <yyoncho <at> gmail.com> writes:

> Sorry, for the short description. Here it is what I can do now:
>
> (json-parse-string  "{\"a\":null}"
>                     :object-type 'plist
>                     :null-object :null-object)
> => (:a :null-object)
>
> Here it is what I want to be able to do also:
>
> (json-parse-string  "{\"a\":{}}"
>                     :object-type 'plist
>                     :empty-object :empty) 
> => (:a :empty)
>
> The purpose of this flag is to be able to distinguish json's null from json's empty
> object.
> ATM this could be achieved only by binding null. I want to be able to bind an
> empty object as well.

I'm not sure I understand the request.  

(json-parse-string  "{\"a\":null, \"b\":{}}"
                    :object-type 'plist)
=> (:a :null :b nil)

(json-parse-string  "{\"a\":null, \"b\":{}}"
                    :object-type 'plist
                    :null-object :null-object)
=> (:a :null-object :b nil)                    

By binding :null-object, you can distinguish these objects already, so
:empty-object would just be the opposite?  And you can do that in
post-filtering if you want something like that.

But I've added Philipp to the CCs; perhaps he has a comment here.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) moreinfo. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sat, 31 Jul 2021 15:08:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41946; Package emacs. (Sat, 31 Jul 2021 15:52:02 GMT) Full text and rfc822 format available.

Message #21 received at 41946 <at> debbugs.gnu.org (full text, mbox):

From: yyoncho <yyoncho <at> gmail.com>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Philipp Stephani <phst <at> google.com>, Eli Zaretskii <eliz <at> gnu.org>,
 41946 <at> debbugs.gnu.org
Subject: Re: bug#41946: 27.0.91;
 native json parsing: add :empty-object configuration
Date: Sat, 31 Jul 2021 18:51:02 +0300
[Message part 1 (text/plain, inline)]
We already have 20k+ LOC project using json null as nil and rebinding it
will force us to rewrite a great portion of the if statements.

Thanks,
Ivan

On Sat, Jul 31, 2021 at 6:07 PM Lars Ingebrigtsen <larsi <at> gnus.org> wrote:

> yyoncho <yyoncho <at> gmail.com> writes:
>
> > Sorry, for the short description. Here it is what I can do now:
> >
> > (json-parse-string  "{\"a\":null}"
> >                     :object-type 'plist
> >                     :null-object :null-object)
> > => (:a :null-object)
> >
> > Here it is what I want to be able to do also:
> >
> > (json-parse-string  "{\"a\":{}}"
> >                     :object-type 'plist
> >                     :empty-object :empty)
> > => (:a :empty)
> >
> > The purpose of this flag is to be able to distinguish json's null from
> json's empty
> > object.
> > ATM this could be achieved only by binding null. I want to be able to
> bind an
> > empty object as well.
>
> I'm not sure I understand the request.
>
> (json-parse-string  "{\"a\":null, \"b\":{}}"
>                     :object-type 'plist)
> => (:a :null :b nil)
>
> (json-parse-string  "{\"a\":null, \"b\":{}}"
>                     :object-type 'plist
>                     :null-object :null-object)
> => (:a :null-object :b nil)
>
> By binding :null-object, you can distinguish these objects already, so
> :empty-object would just be the opposite?  And you can do that in
> post-filtering if you want something like that.
>
> But I've added Philipp to the CCs; perhaps he has a comment here.
>
> --
> (domestic pets only, the antidote for overdose, milk.)
>    bloggy blog: http://lars.ingebrigtsen.no
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41946; Package emacs. (Sat, 31 Jul 2021 16:13:01 GMT) Full text and rfc822 format available.

Message #24 received at 41946 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: yyoncho <yyoncho <at> gmail.com>
Cc: Philipp Stephani <phst <at> google.com>, Eli Zaretskii <eliz <at> gnu.org>,
 41946 <at> debbugs.gnu.org
Subject: Re: bug#41946: 27.0.91; native json parsing: add :empty-object
 configuration
Date: Sat, 31 Jul 2021 18:12:00 +0200
yyoncho <yyoncho <at> gmail.com> writes:

> We already have 20k+ LOC project using json null as nil and rebinding it will
> force us to rewrite a great portion of the if statements.

You can wrap the json calls with a function that flips nil/:empty-object
easy enough, can't you?

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41946; Package emacs. (Sun, 01 Aug 2021 23:55:02 GMT) Full text and rfc822 format available.

Message #27 received at 41946 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Lars Ingebrigtsen <larsi <at> gnus.org>, yyoncho <yyoncho <at> gmail.com>
Cc: Philipp Stephani <phst <at> google.com>, 41946 <at> debbugs.gnu.org
Subject: Re: bug#41946: 27.0.91; native json parsing: add :empty-object
 configuration
Date: Mon, 2 Aug 2021 02:53:56 +0300
On 31.07.2021 19:12, Lars Ingebrigtsen wrote:
> You can wrap the json calls with a function that flips nil/:empty-object
> easy enough, can't you?

By copying the object tree and substituting nil for something else 
recursively?

That says "more GC" to me, which can be a problem when the structure is 
big enough.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41946; Package emacs. (Wed, 04 Aug 2021 05:56:01 GMT) Full text and rfc822 format available.

Message #30 received at 41946 <at> debbugs.gnu.org (full text, mbox):

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: Philipp Stephani <phst <at> google.com>, 41946 <at> debbugs.gnu.org,
 yyoncho <yyoncho <at> gmail.com>
Subject: Re: bug#41946: 27.0.91; native json parsing: add :empty-object
 configuration
Date: Wed, 04 Aug 2021 07:55:04 +0200
Dmitry Gutov <dgutov <at> yandex.ru> writes:

> On 31.07.2021 19:12, Lars Ingebrigtsen wrote:
>> You can wrap the json calls with a function that flips nil/:empty-object
>> easy enough, can't you?
>
> By copying the object tree and substituting nil for something else
> recursively?
>
> That says "more GC" to me, which can be a problem when the structure
> is big enough.

The user didn't want to rewrite the code to alter some conditionals, and
instead wanted Emacs to be changed so that they didn't have to do that.
I pointed out that the user can trivially just pre-process the data if
they didn't want to rewrite those conditionals.

(And they can just modify the structure in place if GC's a concern.)

I think the conclusion here is that we don't want to add :empty-object
to json.c, so I'm closing this bug report.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




Added tag(s) wontfix. Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 04 Aug 2021 05:56:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 41946 <at> debbugs.gnu.org and Ivan Yonchovski <yyoncho <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Wed, 04 Aug 2021 05:56:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41946; Package emacs. (Wed, 04 Aug 2021 10:55:01 GMT) Full text and rfc822 format available.

Message #37 received at 41946 <at> debbugs.gnu.org (full text, mbox):

From: Dmitry Gutov <dgutov <at> yandex.ru>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: Philipp Stephani <phst <at> google.com>, 41946 <at> debbugs.gnu.org,
 yyoncho <yyoncho <at> gmail.com>
Subject: Re: bug#41946: 27.0.91; native json parsing: add :empty-object
 configuration
Date: Wed, 4 Aug 2021 13:54:21 +0300
On 04.08.2021 08:55, Lars Ingebrigtsen wrote:
> The user didn't want to rewrite the code to alter some conditionals, and
> instead wanted Emacs to be changed so that they didn't have to do that.
> I pointed out that the user can trivially just pre-process the data if
> they didn't want to rewrite those conditionals.

It's not like the request is illogical (empty object can also be 
conflated with empty array if json-array-type is 'list'), or it would 
take much effort to implement.

I don't have the time to work on this now, though, so I concede to 
whatever is decided here.




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 01 Sep 2021 11:24:07 GMT) Full text and rfc822 format available.

This bug report was last modified 3 years and 309 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.