DHIS-2 API's

Sir I used that API :
:/api/organisationUnits/OYfCChzZ1wx.json?fields=ancestors,children,name

Response :

{“name”:“Bannu”,“children”:[{“id”:“yvVnd97UiJN”},{“id”:“cdlEAe4BMS2”}],“ancestors”:[{“id”:“osCztkmFYud”},{“id”:“KH8VFLnpwWL”}]}****

···

------------------------------------------------------------------------------------------------------

How Can I get name of the children and ancestors. ??

Hi Omer,

You can try something like this:

?fields=children[name,id],ancestors[name,id]

···

On Thu, Aug 24, 2017 at 12:29 PM, Omer Butt omerbutt2521@gmail.com wrote:

Sir I used that API :
:/api/organisationUnits/OYfCChzZ1wx.json?fields=ancestors,children,name

Response :

{“name”:“Bannu”,“children”:[{“id”:“yvVnd97UiJN”},{“id”:“cdlEAe4BMS2”}],“ancestors”:[{“id”:“osCztkmFYud”},{“id”:“KH8VFLnpwWL”}]}****

------------------------------------------------------------------------------------------------------

How Can I get name of the children and ancestors. ??


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

Em Le Hong
DHIS2 Implementation| **HISP Vietnam **

em.hispvietnam@gmail.com | Skype: em.hispvietnam@gmail.com

Hi Omer Butt,

You can parse/decode this json string by using JavaScript, PHP or Java or any other languages.

**You can parse by JavaScript as below:
**

Result:



You can decode by PHP as below:

<?php $json = '{ "name": "Bannu", "children": [{ "id": "yvVnd97UiJN" }, { "id": "cdlEAe4BMS2" }], "ancestors": [{ "id": "osCztkmFYud" }, { "id": "KH8VFLnpwWL" }] }'; $obj = json_decode($json); print $obj->{'name'}; // Bannu ?>

image

You can parse by Java as below:

https://examples.javacodegeeks.com/core-java/json/java-json-parser-example/

image

···

On Thu, Aug 24, 2017 at 11:29 AM, Omer Butt omerbutt2521@gmail.com wrote:

Sir I used that API :
:/api/organisationUnits/OYfCChzZ1wx.json?fields=ancestors,children,name

Response :

{“name”:“Bannu”,“children”:[{“id”:“yvVnd97UiJN”},{“id”:“cdlEAe4BMS2”}],“ancestors”:[{“id”:“osCztkmFYud”},{“id”:“KH8VFLnpwWL”}]}****

------------------------------------------------------------------------------------------------------

How Can I get name of the children and ancestors. ??


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

If you have any questions or concerns, don’t hesitate to let me know.

Best Regards
Julhas Sujan
Senior Java Programmer
Management Science for Health(MSH)
Dhaka, Bangladesh
Cell: +8801989 442856
Skype: julhas08

www.msh.org http://siapsprogram.org/wherewework/bangladesh/