Skip to content

cod-developers/CIF2JSON

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

CIF <-> JSON

We at the Crystallography Open Database (COD) have been experimenting with CIF <-> JSON conversion for a while. We have arrived at a decision to map the internal representation of CIF files used by our software package cod-tools directly into JSON since v1.1. We have been using 'cod-tools' internal representation (described in Merkys et al., 2016) for some time and though it includes some redundant information, it has proven itself useful in automatically handling CIFs at the COD. Another, low redundancy method has also been proposed.

Main priciples of CIF -> JSON conversion

  1. Top level container is an array instead of an object, thus, order of CIF datablocks (represented as objects) in an input file is retained; uniqueness of datablock names is not enforced;

  2. Data items are keys of values sub-object, thus uniqueness of data names within a data block/save frame is enforced;

  3. Values are always represented as strings exactly as given in CIF file, without losing precision;

  4. Types of values are stored alongside in a sub-object types of datablock. Thus, ? value of type 'unquoted string' is distinguishable from ? value of type 'quoted string' or 'textfield', reducing the need for methods to escape ? and . values with special meanings;

  5. Values of a tag are always stored as an array; there is a sub-object inloop of datablock, which tells whether a tag is looped or not;

  6. Loops, their tags and order are described in sub-array loops of datablock.

Example

Converts CIF file (test.cif) to JSON (test.json):

$ cif2json test.cif > test.json

Pretty-prints converted JSON to test-pp.cif:

$ json_pp < test.json > test-pp.json

About

A proposal for CIF <-> JSON format conversion

Resources

Stars

Watchers

Forks