# Why did Avogadro switch to/develop cjson?

**URL:** <https://discuss.avogadro.cc/t/why-did-avogadro-switch-to-develop-cjson/5128>\
**Category:** Development\
**Created:** [December 14, 2023, 12:05pm UTC](https://discuss.avogadro.cc/t/why-did-avogadro-switch-to-develop-cjson/5128 "2023-12-14T12:05:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![matterhorn103](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/matterhorn103/32/1751_2.png) [@matterhorn103](https://discuss.avogadro.cc/u/matterhorn103)\
**Post date:** [December 14, 2023, 12:05pm UTC](https://discuss.avogadro.cc/t/why-did-avogadro-switch-to-develop-cjson/5128/1 "2023-12-14T12:05:41Z")

</div>

This question is one asked primarily out of interest in the history of the project. 🙂

As a bonus, it would help me understand the merits of adopting `cml` vs `cjson` for a side project of mine.

Originally Avogadro used `cml` as its default file format, and did so for a long time. This had various benefits, as described in the Avogadro paper:

> Avogadro has used CML [[19](https://jcheminf.biomedcentral.com/articles/10.1186/1758-2946-4-17#ref-CR19), [20](https://jcheminf.biomedcentral.com/articles/10.1186/1758-2946-4-17#ref-CR20)] as its default file format from a very early stage; this was chosen over other file formats because of the extensible, semantic structure provided by CML, and the support available in Open Babel [[51](https://jcheminf.biomedcentral.com/articles/10.1186/1758-2946-4-17#ref-CR51)]. The CML format offers a number of advantages over others in common use, including the ability to extend the format. This allows Avogadro and other programs to be future-proof, adding new information and features necessary for an advanced semantically-aware editor at a later time, while still remaining readable in older versions of Avogadro.

From looking at the commit history, it seems like `cjson` support was added in 2012. I can’t quite tell when it became the default in all aspects of the program, but it seems like maybe fairly recently? However, I can’t really find any record of discussions over the change in file format, either here or on GitHub. So I’d be interested to know what the perceived advantages of creating a new format were, and why `cml` no longer fit the bill?

From the chemicaljson repo and the old wiki the main things I can see so far are:

1. `cjson` is a little more efficient storage-wise, as is `json` in general vs `xml`;
2. if I’ve understood correctly, `json` is easy to map to C++ structures so parsing it is faster than `xml`;
3. support for reading `json` amongst programming languages is better than `xml`.

I can see why these would be nice for database or ML applications but they don’t seem like a huge deal for Avogadro, or were they? And the big downside was presumably loss of compatibility with applications using `cml`, which seems pretty significant.

---

<div class="post-metadata">

**Author:** ![ghutchis](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/ghutchis/32/456_2.png) [@ghutchis](https://discuss.avogadro.cc/u/ghutchis)\
**Post date:** [December 14, 2023, 3:07pm UTC](https://discuss.avogadro.cc/t/why-did-avogadro-switch-to-develop-cjson/5128/2 "2023-12-14T15:07:00Z")

</div>

> [@matterhorn103](#):
>
> So I’d be interested to know what the perceived advantages of creating a new format were, and why `cml` no longer fit the bill?

There’s some discussion in this paper: [Open chemistry: RESTful web APIs, JSON, NWChem and the modern web application | Journal of Cheminformatics](https://link.springer.com/article/10.1186/s13321-017-0241-z)

1. JSON has wider support, including in databases (Postgres, Mongo, etc.)
2. There are a few ways to write compressed binary JSON if needed / desired
3. We got fed up with how CML was being updated / maintained (e.g., it’s essentially dead)
4. We’ve been involved with several efforts to have an open standard format for chemistry interchange (esp. in computational chemistry)

MolSSI had a few workshops to encourage a new JSON-based format … and they have their QCSchema format, but frankly, it’s been hard to work with them.

So we’ve been working with `cclib` and anyone who’s interested in adopting and updating `cjson` for other use. Open Babel 3.2 will support full read/write with Avogadro, and IIRC the Grimme tools now support `cjson` as well.

---

<div class="post-metadata">

**Author:** ![matterhorn103](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/matterhorn103/32/1751_2.png) [@matterhorn103](https://discuss.avogadro.cc/u/matterhorn103)\
**Post date:** [December 14, 2023, 7:52pm UTC](https://discuss.avogadro.cc/t/why-did-avogadro-switch-to-develop-cjson/5128/3 "2023-12-14T19:52:17Z")

</div>

Thanks, this was insightful 🙂

> [@ghutchis](#):
>
> IIRC the Grimme tools now support `cjson` as well.

I saw this too, yes. Nice to see it supported elsewhere I imagine, shows it has wider appeal.

---

<div class="post-metadata">

**Author:** ![ghutchis](https://discuss.avogadro.cc/user_avatar/discuss.avogadro.cc/ghutchis/32/456_2.png) [@ghutchis](https://discuss.avogadro.cc/u/ghutchis)\
**Post date:** [December 14, 2023, 9:55pm UTC](https://discuss.avogadro.cc/t/why-did-avogadro-switch-to-develop-cjson/5128/4 "2023-12-14T21:55:36Z")

</div>

One thing I intend for 2024 is to publish an article on the `cjson` format (somewhere) and to push it a bit more outside of Avogadro.
