bug-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


From: yyoncho
Subject: bug#41946: 27.0.91; native json parsing: add :empty-object configuration
Date: Sat, 31 Jul 2021 18:51:02 +0300

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

reply via email to

[Prev in Thread] Current Thread [Next in Thread]