* bug#41946: 27.0.91; native json parsing: add :empty-object configuration
@ 2020-06-19 5:52 Ivan Yonchovski
2020-06-19 7:29 ` Eli Zaretskii
0 siblings, 1 reply; 9+ messages in thread
From: Ivan Yonchovski @ 2020-06-19 5:52 UTC (permalink / raw)
To: 41946
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 {}.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#41946: 27.0.91; native json parsing: add :empty-object configuration
2020-06-19 5:52 bug#41946: 27.0.91; native json parsing: add :empty-object configuration Ivan Yonchovski
@ 2020-06-19 7:29 ` Eli Zaretskii
2020-06-19 8:07 ` yyoncho
0 siblings, 1 reply; 9+ messages in thread
From: Eli Zaretskii @ 2020-06-19 7:29 UTC (permalink / raw)
To: Ivan Yonchovski; +Cc: 41946
> From: Ivan Yonchovski <yyoncho@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?)
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#41946: 27.0.91; native json parsing: add :empty-object configuration
2020-06-19 7:29 ` Eli Zaretskii
@ 2020-06-19 8:07 ` yyoncho
2021-07-31 15:07 ` Lars Ingebrigtsen
0 siblings, 1 reply; 9+ messages in thread
From: yyoncho @ 2020-06-19 8:07 UTC (permalink / raw)
To: Eli Zaretskii; +Cc: 41946
[-- Attachment #1: Type: text/plain, Size: 1074 bytes --]
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@gnu.org> wrote:
> > From: Ivan Yonchovski <yyoncho@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?)
>
[-- Attachment #2: Type: text/html, Size: 1735 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#41946: 27.0.91; native json parsing: add :empty-object configuration
2020-06-19 8:07 ` yyoncho
@ 2021-07-31 15:07 ` Lars Ingebrigtsen
2021-07-31 15:51 ` yyoncho
0 siblings, 1 reply; 9+ messages in thread
From: Lars Ingebrigtsen @ 2021-07-31 15:07 UTC (permalink / raw)
To: yyoncho; +Cc: Philipp Stephani, 41946
yyoncho <yyoncho@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
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#41946: 27.0.91; native json parsing: add :empty-object configuration
2021-07-31 15:07 ` Lars Ingebrigtsen
@ 2021-07-31 15:51 ` yyoncho
2021-07-31 16:12 ` Lars Ingebrigtsen
0 siblings, 1 reply; 9+ messages in thread
From: yyoncho @ 2021-07-31 15:51 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: Philipp Stephani, 41946
[-- Attachment #1: Type: text/plain, Size: 1620 bytes --]
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@gnus.org> wrote:
> yyoncho <yyoncho@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
>
[-- Attachment #2: Type: text/html, Size: 2503 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#41946: 27.0.91; native json parsing: add :empty-object configuration
2021-07-31 15:51 ` yyoncho
@ 2021-07-31 16:12 ` Lars Ingebrigtsen
2021-08-01 23:53 ` Dmitry Gutov
0 siblings, 1 reply; 9+ messages in thread
From: Lars Ingebrigtsen @ 2021-07-31 16:12 UTC (permalink / raw)
To: yyoncho; +Cc: Philipp Stephani, 41946
yyoncho <yyoncho@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
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#41946: 27.0.91; native json parsing: add :empty-object configuration
2021-07-31 16:12 ` Lars Ingebrigtsen
@ 2021-08-01 23:53 ` Dmitry Gutov
2021-08-04 5:55 ` Lars Ingebrigtsen
0 siblings, 1 reply; 9+ messages in thread
From: Dmitry Gutov @ 2021-08-01 23:53 UTC (permalink / raw)
To: Lars Ingebrigtsen, yyoncho; +Cc: Philipp Stephani, 41946
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.
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#41946: 27.0.91; native json parsing: add :empty-object configuration
2021-08-01 23:53 ` Dmitry Gutov
@ 2021-08-04 5:55 ` Lars Ingebrigtsen
2021-08-04 10:54 ` Dmitry Gutov
0 siblings, 1 reply; 9+ messages in thread
From: Lars Ingebrigtsen @ 2021-08-04 5:55 UTC (permalink / raw)
To: Dmitry Gutov; +Cc: Philipp Stephani, 41946, yyoncho
Dmitry Gutov <dgutov@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
^ permalink raw reply [flat|nested] 9+ messages in thread
* bug#41946: 27.0.91; native json parsing: add :empty-object configuration
2021-08-04 5:55 ` Lars Ingebrigtsen
@ 2021-08-04 10:54 ` Dmitry Gutov
0 siblings, 0 replies; 9+ messages in thread
From: Dmitry Gutov @ 2021-08-04 10:54 UTC (permalink / raw)
To: Lars Ingebrigtsen; +Cc: Philipp Stephani, 41946, yyoncho
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.
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2021-08-04 10:54 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-06-19 5:52 bug#41946: 27.0.91; native json parsing: add :empty-object configuration Ivan Yonchovski
2020-06-19 7:29 ` Eli Zaretskii
2020-06-19 8:07 ` yyoncho
2021-07-31 15:07 ` Lars Ingebrigtsen
2021-07-31 15:51 ` yyoncho
2021-07-31 16:12 ` Lars Ingebrigtsen
2021-08-01 23:53 ` Dmitry Gutov
2021-08-04 5:55 ` Lars Ingebrigtsen
2021-08-04 10:54 ` Dmitry Gutov
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).