Re: CIF-JSON new draft
- Subject: Re: CIF-JSON new draft
- From: James Hester <jamesrhester@xxxxxxxxx>
- Date: Fri, 5 May 2017 16:45:52 +1000
- DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025;h=mime-version:in-reply-to:references:from:date:message-id:subject:to;bh=mlhCh+EhBp625V0Wd5eyOgUKjV21d31cEK46gn6ps3Y=;b=q4lBRivTSJiW/RWoBguJmKWP19u6I1jNr1j95YJWMlmGk3Xci1X42F2bO6rcRRIFraBLrN1+xVl2iXcdDQdvOfJils2nv5xTxoWD0aMZiYJAk15PhJFgn90pbaqxKypqXF4n5Pq3A9DIuHRnVNqyGta4Yp11WLpwdcIy7dU4UNvJpifr7t6tM5LuxEfIa9/SZvOKdvf2QhNZRZNqxJdXlt0Fa7Pf7XPqrINVMzc23c4BG7epAxvwUFfa0e2m12YdkXFC21cz3OGbDwzW30xkSH5IYhyCH+VFu9vsulVNH2t7J7sYfGxG003gglUIV1Nkr5YJFaYjbt27PTR0il2zgA==
- In-Reply-To: <MWHPR04MB0512919511496E7B5E5C526DE0EA0@MWHPR04MB0512.namprd04.prod.outlook.com>
- References: <CAM+dB2ey9kKLoZY=WE7Uy-fiWTGhQaFx7fcgODcYfhrNPwXkQw@mail.gmail.com><MWHPR04MB05123A9F46812A3372A252FCE0160@MWHPR04MB0512.namprd04.prod.outlook.com><MWHPR04MB051249D1082721C51E84232FE0160@MWHPR04MB0512.namprd04.prod.outlook.com><CAF_YUvVjKTmCC18=pNGgANU25phE8Gij9=boT=nw8vUZQKPHmw@mail.gmail.com><CACaHzQVW=koD_QV+70veqQL0PFQxLkB_Xhgs61xGK6_FTr91Fw@mail.gmail.com><CAF_YUvXkWoPFpgHe7u4Pr+h7SLtpypmAU0aSBfFD294fQdUvZA@mail.gmail.com><MWHPR04MB0512919511496E7B5E5C526DE0EA0@MWHPR04MB0512.namprd04.prod.outlook.com>
json-c/wiki), which seems to be one of the more popular C implementations. It uses C null pointers to represent JSON null values, and its functions for accessing array elements and object fields return null when no such field or element exists. The case of a null-valued field or array element is thus difficult (but not impossible) to distinguish from the case where there is no such field or element at all.
In the particular case of JSON-C, this appears to be a recognized shortcoming. The most recent version provides a new function for accessing object fields that works around the problem, though it is not a drop-in replacement for the old. I anticipate that similar issues will be relatively common in other implementations, however, and it would be naïve to suppose that such implementations will not be used to handle CIF-JSON.
Now, this may be an issue that we simply choose to accept. I never said it was *impossible* to distinguish between absent and present-but-null in any implementation I know about or contemplate, so it is not a fatal flaw. But I am considering how to make CIF-JSON as easy to program for as possible, by making design choices that minimize gotchas for users.
From: cif-developers [mailto:cif-developers-
email@example.com] On Behalf Of Robert Hanson
Sent: Wednesday, May 03, 2017 6:20 PM
To: Forum for CIF software developers <firstname.lastname@example.org>
Subject: Re: CIF-JSON new draft
That's true. I hadn't thought of that. Of course, that's what the === operator is for.
John, what's the issue?
On Wed, May 3, 2017 at 5:53 PM, Marcin Wojdyr <email@example.com> wrote:
On 3 May 2017 at 23:41, Robert Hanson <firstname.lastname@example.org> wrote:
> John has an interesting point. For example:
> "_chemical_formula_sum": null
> cannot be distinguished easily from
> (You can iterate through all keys to see if one is missing, but that is not
> typically how it is done.)
If it's about JS I don't understand your point. In one case the
property is null and in the other it's undefined. Clearly different.
cif-developers mailing list
Robert M. Hanson
Larson-Anderson Professor of Chemistry
St. Olaf College
If nature does not answer first what we want,
it is better to take what answer we get.
-- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900
Email Disclaimer: www.stjude.org/emaildisclaimer
Consultation Disclaimer: www.stjude.org/
cif-developers mailing list
F +61 (02) 9717 3145
M +61 (04) 0249 4148
_______________________________________________ cif-developers mailing list email@example.com http://mailman.iucr.org/cgi-bin/mailman/listinfo/cif-developers
Reply to: [list | sender only]
- Re: CIF-JSON new draft (Marcin Wojdyr)