Skip to content

Commit 372fe65

Browse files
committed
Short value by default in TOML
1 parent 196e052 commit 372fe65

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

docs/source/backends/json.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Attributes
6767
In order to avoid name clashes, attributes are generally stored within a separate subgroup ``attributes``.
6868

6969
Attributes can be stored in two formats.
70-
The format is selected by the :ref:`JSON/TOML parameter<backendconfig>` ``json.attribute.mode`` (resp. ``toml.attribute.mode``) with possible values ``["long", "short"]`` (default: ``"long"`` in openPMD 1.*, ``"short"`` in openPMD >= 2.0).
70+
The format is selected by the :ref:`JSON/TOML parameter<backendconfig>` ``json.attribute.mode`` (resp. ``toml.attribute.mode``) with possible values ``["long", "short"]`` (default: ``"long"`` for JSON in openPMD 1.*, ``"short"`` otherwise, i.e. generally in openPMD 2.*, but always in TOML).
7171

7272
Attributes in **long format** store the datatype explicitly, by representing attributes as JSON objects.
7373
Every such attribute is itself a JSON object with two keys:

src/IO/JSON/JSONIOHandlerImpl.cpp

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,18 @@ void JSONIOHandlerImpl::createFile(
457457

458458
if (m_attributeModeSpecificationVia == SpecificationVia::DefaultValue)
459459
{
460-
m_attributeMode = parameters.openPMDversion >= "2."
461-
? AttributeMode::Short
462-
: AttributeMode::Long;
460+
switch (m_fileFormat)
461+
{
462+
463+
case FileFormat::Json:
464+
m_attributeMode = parameters.openPMDversion >= "2."
465+
? AttributeMode::Short
466+
: AttributeMode::Long;
467+
break;
468+
case FileFormat::Toml:
469+
m_attributeMode = AttributeMode::Short;
470+
break;
471+
}
463472
}
464473

465474
if (!writable->written)

0 commit comments

Comments
 (0)