# Loading JSON/XML data

**URL:** <https://discourse.slicer.org/t/loading-json-xml-data/1445>\
**Category:** Support\
**Created:** [November 13, 2017, 2:30pm UTC](https://discourse.slicer.org/t/loading-json-xml-data/1445 "2017-11-13T14:30:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdx-john](https://avatars.discourse-cdn.com/v4/letter/j/a6a055/32.png) [@jdx-john](https://discourse.slicer.org/u/jdx-john)\
**Post date:** [November 13, 2017, 2:30pm UTC](https://discourse.slicer.org/t/loading-json-xml-data/1445/1 "2017-11-13T14:30:23Z")

</div>

[https://www.slicer.org/wiki/Documentation/Nightly/SlicerApplication/SupportedDataFormat](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?

---

<div class="post-metadata">

**Author:** ![ihnorton](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/ihnorton/32/9_2.png) [@ihnorton](https://discourse.slicer.org/u/ihnorton)\
**Post date:** [November 13, 2017, 2:52pm UTC](https://discourse.slicer.org/t/loading-json-xml-data/1445/2 "2017-11-13T14:52:59Z")

</div>

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)

---

<div class="post-metadata">

**Author:** ![jdx-john](https://avatars.discourse-cdn.com/v4/letter/j/a6a055/32.png) [@jdx-john](https://discourse.slicer.org/u/jdx-john)\
**Post date:** [November 13, 2017, 3:17pm UTC](https://discourse.slicer.org/t/loading-json-xml-data/1445/3 "2017-11-13T15:17:38Z")

</div>

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 🙂

---

<div class="post-metadata">

**Author:** ![lassoan](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/lassoan/32/13_2.png) [@lassoan](https://discourse.slicer.org/u/lassoan)\
**Post date:** [November 13, 2017, 4:00pm UTC](https://discourse.slicer.org/t/loading-json-xml-data/1445/4 "2017-11-13T16:00:02Z")

</div>

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