guile-user
[Top][All Lists]
Advanced

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

Problems with JSON null


From: John Cowan
Subject: Problems with JSON null
Date: Wed, 2 Jan 2019 09:31:09 -0500

In the current version of guile-json, JSON null is represented internally
as #nil.  Because of the magic behavior of #nil, this causes certain
problems when trying to discriminate between various internal JSON
representations.  For example, the programmer will expect (list? j) to
detect a JSON object and (null? j) to detect an empty JSON object.  But
these type discriminators are not correct, because they will also return #t
on #nil.  So one must write unidiomatic things like (or (pair? j) ((eq? j
'())) instead of (list? j).

I suggest (even though it is yet another breaking change) switching to the
Scheme symbol null.  This is portable, printable and rereadable, and not
subject to the above problems.


reply via email to

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