Skip to content

Commit bc141aa

Browse files
committed
Add documentation for TOML
1 parent d203d10 commit bc141aa

File tree

1 file changed

+28
-6
lines changed

1 file changed

+28
-6
lines changed

docs/source/backends/json.rst

Lines changed: 28 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
.. _backends-json:
22

3-
JSON
4-
====
3+
JSON/TOML
4+
=========
55

6-
openPMD supports writing to and reading from JSON files.
7-
The JSON backend is always available.
6+
openPMD supports writing to and reading from JSON and TOML files.
7+
The JSON and TOML backends are always available.
88

99

1010
JSON File Format
@@ -43,9 +43,17 @@ Every such attribute is itself a JSON object with two keys:
4343
* ``datatype``: A string describing the type of the value.
4444
* ``value``: The actual value of type ``datatype``.
4545

46+
TOML File Format
47+
----------------
48+
49+
A TOML file uses the file ending ``.toml``. The TOML backend is chosen by creating a ``Series`` object with a filename that has this file ending.
50+
51+
The TOML backend internally works with JSON datasets and converts to/from TOML during I/O.
52+
As a result, data layout and usage are equivalent to the JSON backend.
4653

47-
Restrictions
48-
------------
54+
55+
JSON Restrictions
56+
-----------------
4957

5058
For creation of JSON serializations (i.e. writing), the restrictions of the JSON backend are
5159
equivalent to those of the `JSON library by Niels Lohmann <https://github.com/nlohmann/json>`_
@@ -77,6 +85,20 @@ The (keys) names ``"attributes"``, ``"data"`` and ``"datatype"`` are reserved an
7785

7886
A parallel (i.e. MPI) implementation is *not* available.
7987

88+
TOML Restrictions
89+
-----------------
90+
91+
Note that the JSON datatype-specific restrictions do not automatically hold for TOML, as those affect only the representation on disk, not the internal representation.
92+
93+
TOML supports most numeric types, up to long double and long long types.
94+
Special floating point values such as NaN are also support.
95+
96+
TOML does not support null values.
97+
98+
The (keys) names ``"attributes"``, ``"data"`` and ``"datatype"`` are reserved and must not be used for base/mesh/particles path, records and their components.
99+
100+
A parallel (i.e. MPI) implementation is *not* available.
101+
80102

81103
Example
82104
-------

0 commit comments

Comments
 (0)