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

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

Re: How to test for native JSON support?


From: Eli Zaretskii
Subject: Re: How to test for native JSON support?
Date: Tue, 04 May 2021 15:50:23 +0300

> From: Joost Kremers <joostkremers@fastmail.fm>
> Cc: help-gnu-emacs@gnu.org
> Date: Tue, 04 May 2021 14:29:53 +0200
> 
> > It actually displays an error message, in addition to returning nil
> > (as do all other JSON primitives in that case).
> 
> So should I wrap my call to `(json-serialize '((test . 1)))` in 
> `ignore-errors`

It doesn't signal an error, just displays a message.  So it
effectively already does ignore-errors.

> if I don't want to worry unsuspecting users with a (possibly to them arcane)
> error message? (Unfortunately, I don't have access to a Windows machine so I
> can't test this myself.)

The message is "jansson library not found".

But to answer your question, you should allow the user to determine
whether the built-in or the Lisp implementation will be used, because
only the user knows whether the library is installed.

> And is there a reason why the native json-functions do not gracefully degrade 
> to
> their counterparts in the `json.el` library?

First, because no one wrote the code to do that; patches welcome.
Second, because the implementations are not 100% equivalent, neither
in the API names nor in some aspects of the functionality.  So
automatic replacement is not trivial, not in general anyway.



reply via email to

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