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>
The issue is primarily with JSON implementations other than JavaScript’s, though to a lesser extent, it is also with presenting a gotcha in JS context. For example, I have been playing around with JSON-C (https://github.com/json-c/
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.
John
From: cif-developers [mailto:cif-developers-
bounces@iucr.org ] On Behalf Of Robert Hanson
Sent: Wednesday, May 03, 2017 6:20 PM
To: Forum for CIF software developers <cif-developers@iucr.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.
Never mind.John, what's the issue?
On Wed, May 3, 2017 at 5:53 PM, Marcin Wojdyr <wojdyr@gmail.com> wrote:
On 3 May 2017 at 23:41, Robert Hanson <hansonr@stolaf.edu> 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.
Marcin
_______________________________________________
cif-developers mailing list
cif-developers@iucr.org
http://mailman.iucr.org/cgi-bin/mailman/listinfo/cif- developers
--Robert M. Hanson
Larson-Anderson Professor of Chemistry
St. Olaf College
Northfield, MN
http://www.stolaf.edu/people/hansonr
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/consultationdisclaimer
_______________________________________________
cif-developers mailing list
cif-developers@iucr.org
http://mailman.iucr.org/cgi-bin/mailman/listinfo/cif- developers
--
F +61 (02) 9717 3145
M +61 (04) 0249 4148
_______________________________________________ cif-developers mailing list cif-developers@iucr.org http://mailman.iucr.org/cgi-bin/mailman/listinfo/cif-developers
Reply to: [list | sender only]
- Follow-Ups:
- Re: CIF-JSON new draft (Marcin Wojdyr)
- References:
- CIF-JSON new draft (James Hester)
- RE: CIF-JSON new draft (Bollinger, John C)
- RE: CIF-JSON new draft (Bollinger, John C)
- Re: CIF-JSON new draft (Robert Hanson)
- Re: CIF-JSON new draft (Marcin Wojdyr)
- Re: CIF-JSON new draft (Robert Hanson)
- RE: CIF-JSON new draft (Bollinger, John C)
- Prev by Date: Re: CIF-JSON new draft
- Next by Date: Re: CIF-JSON new draft
- Prev by thread: RE: CIF-JSON new draft
- Next by thread: Re: CIF-JSON new draft
- Index(es):