SDMX-JSON

Currently, with this format, only structural metadata and reference metadata are supported in pysdmx. The SDMX-JSON readers and writers are compatible with SDMX-JSON 2.0.0 standard.

SDMX-JSON 2.0.0 Structure Message

SDMX-JSON 2.0.0 Metadata Message

Reading

Although the use of the general reader is always recommended, specific readers for SDMX-JSON are also available:

  • STRUCTURE_SDMX_JSON_2_0_0 -> pysdmx.io.json.sdmxjson2.reader.structure

pysdmx.io.json.sdmxjson2.reader.structure.read(input_str)

Read an SDMX-JSON 2.0.0 Stucture Message.

Parameters:

input_str (str) – SDMX-JSON structure message to read.

Return type:

StructureMessage

Returns:

A pysdmx StructureMessage

  • REFMETA_SDMX_JSON_2_0_0 -> pysdmx.io.json.sdmxjson2.reader.metadata

pysdmx.io.json.sdmxjson2.reader.metadata.read(input_str)

Read an SDMX-JSON 2.0.0 Metadata Message.

Parameters:

input_str (str) – SDMX-JSON reference metadata message to read.

Return type:

MetadataMessage

Returns:

A pysdmx MetadataMessage

Writing

Although the use of the general writer is always recommended, specific writers for SDMX-JSON are also available:

  • STRUCTURE_SDMX_JSON_2_0_0 -> pysdmx.io.json.sdmxjson2.writer.structure

pysdmx.io.json.sdmxjson2.writer.structure.write(structures, output_path=None, prettyprint=True, header=None)

Write maintainable SDMX artefacts in SDMX-JSON 2.0.0.

Parameters:
  • structures (Sequence[MaintainableArtefact]) – The maintainable SDMX artefacts to be serialized.

  • output_path (Union[str, Path, None]) – The path to save the JSON file. If None or empty, the serialized content is returned as a string instead.

  • prettyprint (bool) – Whether to format the JSON output with indentation (True) or output compact JSON without extra whitespace (False).

  • header (Optional[Header]) – The header to be used in the SDMX-JSON message (will be generated if no header is supplied).

Return type:

Optional[str]

Returns:

The JSON string if output_path is None or empty, None otherwise.

  • REFMETA_SDMX_JSON_2_0_0 -> pysdmx.io.json.sdmxjson2.writer.metadata

pysdmx.io.json.sdmxjson2.writer.metadata.write(reports, output_path=None, prettyprint=True, header=None)

Write metadata reports in SDMX-JSON 2.0.0.

Parameters:
  • reports (Sequence[MetadataReport]) – The reference metadata reports to be serialized.

  • output_path (Union[str, Path, None]) – The path to save the JSON file. If None or empty, the serialized content is returned as a string instead.

  • prettyprint (bool) – Whether to format the JSON output with indentation (True) or output compact JSON without extra whitespace (False).

  • header (Optional[Header]) – The header to be used in the SDMX-JSON message (will be generated if no header is supplied).

Return type:

Optional[str]

Returns:

The JSON string if output_path is None or empty, None otherwise.