Is your feature request related to a problem? Please describe.
As discussed on IATI Connect, there are advantages to outputting JSON data in a consistent format. However, at the moment, by default, Datastore Classic outputs a single element as an object rather than an array. For example, one sector:
It would be preferable to output elements in a consistent way. However: perhaps this should be done only for elements that can occur more than once. For example, <activity-status> can only occur once, so it should probably be output as an object.
In the xmltodict library, you can use the force_list parameter to force elements to be output as arrays.
If we were to implement this, it would probably need to be on a new v2 endpoint as it represents a significant change to the API. Alternatively, the output could be requested via an optional parameter, similar to the unwrap parameter that can be requested on the xml formatted endpoints.
Describe alternatives you’ve considered
Checking whether the values in an element are an array or an object.
Is your feature request related to a problem? Please describe.
As discussed on IATI Connect, there are advantages to outputting JSON data in a consistent format. However, at the moment, by default, Datastore Classic outputs a single element as an object rather than an array. For example, one sector:
Would be output as an object:
Whereas two sectors:
Would be output as an array:
Describe the solution you’d like
It would be preferable to output elements in a consistent way. However: perhaps this should be done only for elements that can occur more than once. For example,
<activity-status>
can only occur once, so it should probably be output as an object.In the
xmltodict
library, you can use theforce_list
parameter to force elements to be output as arrays.If we were to implement this, it would probably need to be on a new v2 endpoint as it represents a significant change to the API. Alternatively, the output could be requested via an optional parameter, similar to the
unwrap
parameter that can be requested on thexml
formatted endpoints.Describe alternatives you’ve considered
Checking whether the values in an element are an array or an object.
Additional context
See e.g. sample JSON: https://datastore.codeforiati.org/api/1/access/activity.json?reporting-org=CA-3&limit=1&ref=qb&locale=en