Loading JSON/XML data

https://www.slicer.org/wiki/Documentation/Nightly/SlicerApplication/SupportedDataFormat lists many image and related formats.

But what if I have some custom data in JSON or XML files… not a dataset, some arbitrary data needed by an extension feature or to feed into VTK functions.
Is built-in loading/parsing of such files supported in Slicer?

for C++:

  • JSON: both RapidJSON and jsoncpp are available (I think jsoncpp will eventually be removed, but could be wrong about that)
  • XML: MRML is an XML variant, parsed with VTK’s API over libxml2. You could probably use whichever is most convenient.

for Python:

  • import json, import xml (although there are nicer external libraries for both)

Python is most likely though I’m not a Python dev… are you saying
’json’/‘xml’ are already used in Slicer or are parts of Slicer available to
Python scripts? This seems an easy answer :slight_smile:

Yes, both json and xml files are used extensively in Slicer.