Hi Knut, What are you using for parsing JSON (which library)?
In general you should never rely on order of items in JSON. It is better to interpret it as a "map" rather than "list". Best Regards, Araz On Sun, Nov 22, 2015 at 7:32 AM, Knut Staring <knu...@gmail.com> wrote: > > Below is a patient tracked entity instance > > > > In order to get a first name or a last name from this attribute list, we > would have to loop through all the attributes until we find an attribute > that has the displayName "firstName", as all the attribute seem to be in > random order for each patient. That is inefficient and clunky. Is there a > way to get the data in a format that could be read by javascript more > easily? > > > > { > "lastUpdated":"2014-03-28 12:33:47.354", > "trackedEntity":"G0PlBqu2Boe", > "created":"2014-03-26 15:46:02.45", > "orgUnit":"DiszpKrYNg8", > "trackedEntityInstance":"JRm9etA1dG1", > "relationships":[ > > ], > "attributes":[ > { > "code":"MMD_PER_NAM", > "displayName":"First name", > "valueType":"TEXT", > "attribute":"w75KJ2mc4zz", > "value":"Kedija" > }, > { > "displayName":"Gender", > "valueType":"TEXT", > "attribute":"cejWyOfXge6", > "value":"Female" > }, > > ... > ] > }, > > > > I tried something like the below, but that doesn't seem to work. What am I > missing? > > > > https://play.dhis2.org/demo/api/trackedEntityInstances/PQfMcpmXeFE.json?fields=attributes[displayName]&filter=attributes[displayName]:eq:Gender > > > > > > _______________________________________________ > Mailing list: https://launchpad.net/~dhis2-devs > Post to : dhis2-devs@lists.launchpad.net > Unsubscribe : https://launchpad.net/~dhis2-devs > More help : https://help.launchpad.net/ListHelp > >
_______________________________________________ Mailing list: https://launchpad.net/~dhis2-devs Post to : dhis2-devs@lists.launchpad.net Unsubscribe : https://launchpad.net/~dhis2-devs More help : https://help.launchpad.net/ListHelp