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: Lars Ingebrigtsen
Subject: bug#41946: 27.0.91; native json parsing: add :empty-object configuration
Date: Sat, 31 Jul 2021 17:07:01 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

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]