Hi Dale,
You could also consider using the OIPA API. Dependent on your views of ‘in its original XML format’.
In my opinion/experience its not very practical to map IATI XML 1:1 to JSON. There’s some considerations with regards to JSON styling practices and making the API useful. Here’s the alterations with regards to IATI -> JSON mapping in OIPA.
-
Hyphens are replaced by underscores in JSON keys. Some users (and we ourselves) prefer dot notation to access properties in javascript, that would be troublesome with hyphens. It’s a minor thing and a discutable solution, we prefer practical use of the API.
-
XML elements that can occur multiple times, become a list in JSON. IN JSON its common practice to make list keys plural.
-
In OIPA most code lists are nested in the JSON. When using IATI XML 1:1 as JSON, you’ll have to keep all the used code lists on your front-end. In some cases that’s desirable, in most cases it isn’t. It could also cause bugs when you don’t keep that code lists up-to-date (you’ll have to maintain that for every front-end).
Here’s an example that shows all three of these alterations;
"recipient_countries": [{"country": {"code": "TZ", "name": "Tanzania, united republic of"},"percentage": 30.0}]
1:1 mapping would be:
"recipient-country": [{"code": "TZ", "percentage": 30.0}]
These are all just design decision with practical use on front-end websites in mind. I would be interested to hear other views on these issues!