From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Joost Kremers Newsgroups: gmane.emacs.help Subject: Re: How to test for native JSON support? Date: Tue, 04 May 2021 14:29:53 +0200 Message-ID: <87fsz2n075.fsf@fastmail.fm> References: <87k0ohuybx.fsf@fastmail.fm> <785b4132-da32-0da8-519d-b39a58270f32@gmail.com> <87y2cuybeu.fsf@passepartout.tim-landscheidt.de> <838s4u66f0.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="36372"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.5.12; emacs 27.2 Cc: help-gnu-emacs@gnu.org To: Eli Zaretskii Original-X-From: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Tue May 04 14:39:42 2021 Return-path: Envelope-to: geh-help-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lduL0-0009N1-1a for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 04 May 2021 14:39:42 +0200 Original-Received: from localhost ([::1]:51120 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lduKz-0003D6-3g for geh-help-gnu-emacs@m.gmane-mx.org; Tue, 04 May 2021 08:39:41 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58558) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lduJq-0003D0-R2 for help-gnu-emacs@gnu.org; Tue, 04 May 2021 08:38:30 -0400 Original-Received: from out2-smtp.messagingengine.com ([66.111.4.26]:51757) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lduJm-0005M9-7b; Tue, 04 May 2021 08:38:30 -0400 Original-Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 4E0B15C00C9; Tue, 4 May 2021 08:38:25 -0400 (EDT) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Tue, 04 May 2021 08:38:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=fastmail.fm; h= references:from:to:cc:subject:date:in-reply-to:message-id :mime-version:content-type; s=fm3; bh=8motvmn8LgwgtYzfoiUvrRMj6I LTVXcHKLG8VTtsfvk=; b=W1tK/DDFc646X+jKghpjtAhdiO/huUFdzw16H69we4 ryKF6BnaGY/R+0bRep2vEXT5ynZWaxeJnVj81YUYzio5o5+YBOiQXVtns4EW4Y4C +hcQg0txUPS1rc8RNxoOqGlESB18F9TJQr3i5jUlgA/k8rgVI4iUVEM+cVxb+uUT EJzrvoobPuWV6ibFY93tKH+joei2up5a0oxNgecXcFcY/CSJCfpanIXMzGQ22BgT vDmAvOEyzYNhhqu2FKFqZT6rS4milGu/DQDGNTP+Og/Ev1RdUBhmfHLiSCNIliCS pkKr+UnZjNRVv2Hwut2cnUze1kmQpKBz5BdgsX0dkUcw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=8motvm n8LgwgtYzfoiUvrRMj6ILTVXcHKLG8VTtsfvk=; b=FforQZIsN8nTJ+qRTHbkQH Yjk/AMOymbmURxhhyiLiVMh4QtEUfl+5b0ZiQLNOUIOQG9OhedNaBDLSBUDLDX01 4wM2eqZW13/qJuboopjxaFpJ1hXBqtGdzkOiNxyOvXg20i7q9gZFSrf6ZN9AjewN ef/yGbAFx/8FDYrUUa98WReVKwCMUQBVUfrsA+zi/g4nRiawJP4tLdOnC5EgcdM+ I042qowINwEdAVmESIoetHalFSQXwTIVN+BKhqMThf9hZxCC9xw8ZsczpNsuj/Wo KDr1yS2pj6dmKo8b92wzh4PI9VWuy0Pq0UzEoUWy5oh4xNeA9YNW511Nb4HuPThQ == X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdefiedgheeiucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfhgfhffvufffjgfkgggtsehttdertddtredtnecuhfhrohhmpeflohhoshht ucfmrhgvmhgvrhhsuceojhhoohhsthhkrhgvmhgvrhhssehfrghsthhmrghilhdrfhhmqe enucggtffrrghtthgvrhhnpedviefhteeuveekudetheduieehvdelgfeijeehvdetfeeg leelhefhjeduieejveenucfkphepfedurddujedrvdehuddrudelleenucevlhhushhtvg hrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehjohhoshhtkhhrvghmvghr shesfhgrshhtmhgrihhlrdhfmh X-ME-Proxy: Original-Received: from Lenovo.fastmail.com (ip1f11fbc7.dynamic.kabel-deutschland.de [31.17.251.199]) by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 4 May 2021 08:38:24 -0400 (EDT) In-reply-to: <838s4u66f0.fsf@gnu.org> Received-SPF: pass client-ip=66.111.4.26; envelope-from=joostkremers@fastmail.fm; helo=out2-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: help-gnu-emacs@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Users list for the GNU Emacs text editor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: help-gnu-emacs-bounces+geh-help-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "help-gnu-emacs" Xref: news.gmane.io gmane.emacs.help:129420 Archived-At: On Tue, May 04 2021, Eli Zaretskii wrote: >> From: Tim Landscheidt >> Date: Tue, 04 May 2021 11:40:41 +0000 >> >> Nikolay Kudryavtsev wrote: >> >> > json-serialize would return nil if libjansson library is not >> > available during the execution time. So the scenario would >> > be someone building Emacs with json support, then forgetting >> > to put libjansson on his path and/or moving the binary to >> > another machine. Not very likely to happen on any POSIX >> > systems, but a more or less tangible case on Windows. >> >> That's a rather unexpected, at least undocumented failure >> mode (vulgo: a bug). IMNSHO in that case json-serialize >> should either "work" or throw an error. > > 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` 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.) And is there a reason why the native json-functions do not gracefully degrade to their counterparts in the `json.el` library? That seems like the logical thing to do and would render testing for native JSON support unnecessary, but perhaps there's a reason for not doing it. -- Joost Kremers Life has its moments