[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH] Support custom 'null' and 'false' objects when parsing JSON
From: |
João Távora |
Subject: |
Re: [PATCH] Support custom 'null' and 'false' objects when parsing JSON |
Date: |
Fri, 08 Jun 2018 00:08:28 +0100 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) |
Stefan Monnier <address@hidden> writes:
>> the keyword :null, I have to explicitly check for non-`nil'ness *and*
>> non-`:null'ness, whereas before only one check was necessary. Other
>
> IIUC this is a matter of changing things like
>
> (null x)
> to
> (memq x '(nil :null))
>
> right? On this one example it doesn't look that bad
More like from
x
to
(not (memq x '(nil :null)))
or to
(and (not (memq x '(nil :null))) x)
if you're planning on destructuring x
Not exactly pretty. Sure, I could change `when's to `unless`es, or wrap
that in a macro, but still akward.
Also, I don't see why we shouldn't work towards some (or total) json.el
compatibility, presuming it's easy and cheap like in this case here.
>> -json_to_lisp (json_t *json, enum json_object_type object_type)
>> +json_to_lisp (json_t *json,
>> + enum json_object_type object_type,
>> + Lisp_Object null_object,
>> + Lisp_Object false_object)
>
> Wouldn't it make sense to group those 3 parameters into a single object
> (presumably a pointer to a stack-allocated struct containing those
> 3 fields)?
Yes it would, good idea.
João