Discussion List Archives

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

RE: CIF-JSON new draft

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.





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.

cif-developers mailing list


Robert M. Hanson
Larson-Anderson Professor of Chemistry
St. Olaf College
Northfield, MN

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

Reply to: [list | sender only]
International Union of Crystallography

Scientific Union Member of the International Science Council (admitted 1947). Member of CODATA, the ISC Committee on Data. Partner with UNESCO, the United Nations Educational, Scientific and Cultural Organization in the International Year of Crystallography 2014.

International Science Council Scientific Freedom Policy

The IUCr observes the basic policy of non-discrimination and affirms the right and freedom of scientists to associate in international scientific activity without regard to such factors as ethnic origin, religion, citizenship, language, political stance, gender, sex or age, in accordance with the Statutes of the International Council for Science.