|
1 | 1 | .. _backends-json: |
2 | 2 |
|
3 | | -JSON |
4 | | -==== |
| 3 | +JSON/TOML |
| 4 | +========= |
5 | 5 |
|
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. |
8 | 8 |
|
9 | 9 |
|
10 | 10 | JSON File Format |
@@ -43,9 +43,17 @@ Every such attribute is itself a JSON object with two keys: |
43 | 43 | * ``datatype``: A string describing the type of the value. |
44 | 44 | * ``value``: The actual value of type ``datatype``. |
45 | 45 |
|
| 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. |
46 | 53 |
|
47 | | -Restrictions |
48 | | ------------- |
| 54 | + |
| 55 | +JSON Restrictions |
| 56 | +----------------- |
49 | 57 |
|
50 | 58 | For creation of JSON serializations (i.e. writing), the restrictions of the JSON backend are |
51 | 59 | 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 |
77 | 85 |
|
78 | 86 | A parallel (i.e. MPI) implementation is *not* available. |
79 | 87 |
|
| 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 | + |
80 | 102 |
|
81 | 103 | Example |
82 | 104 | ------- |
|
0 commit comments