# Extracting director data from JSON

**URL:** <http://forum.companieshouse.gov.uk/t/extracting-director-data-from-json/6040>\
**Category:** API Question\
**Created:** [March 16, 2023, 4:15pm UTC](http://forum.companieshouse.gov.uk/t/extracting-director-data-from-json/6040 "2023-03-16T16:15:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![liamcooke.jones](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/l/9d8465/32.png) [@liamcooke.jones](http://forum.companieshouse.gov.uk/u/liamcooke.jones)\
**Post date:** [March 16, 2023, 4:15pm UTC](http://forum.companieshouse.gov.uk/t/extracting-director-data-from-json/6040/1 "2023-03-16T16:15:36Z")

</div>

I have the below code to extract the directors names from the JSON response I get from the API however it just always returns null, null, null. Any ideas?

" //Number of officers  
NumberOfOfficers = response.get(“active\_count”);  
info NumberOfOfficers;  
nameList = Collection();  
for each NumberOfOfficers in response  
{  
nameList.insert(response.getjson(“links:/items:/name”));  
}  
info nameList;  
}  
return “Complete”;"

Json Response I am getting

" \* “{“responseText”:{“items”:[{“appointed\_on”:“2021-11-01”,“address”:{“country”:“United Kingdom”,“locality”:“London”,“postal\_code”:“SW1E 5NN”,“address\_line\_1”:“Victoria Street”,“premises”:“171”},“officer\_role”:“secretary”,“name”:“CHEONG TUNG SING, Jane Christina”,“links”:{“officer”:{“appointments”:”/officers/LG\_egxtJWL43Os-6mEhljPNd2jM/appointments"},“self”:"/company/00233462/appointments/SjlBhiCCMhBB3ugmmxZNa1Z82mU"}},{“date\_of\_birth”:{“year”:1973,“month”:11},“country\_of\_residence”:“England”,“occupation”:“Director”,“name”:“MICHEL, Berangere Andree Mireille”,“links”:{“self”:"/company/00233462/appointments/FE4G5d41wfGEuB-4QQE3FqWuuzI",“officer”:{“appointments”:"/officers/9215jCvRXjjcnqAxDJX6G7WOYjc/appointments"}},“officer\_role”:“director”,“address”:{“address\_line\_2”:“London”,“postal\_code”:“SW1E 5NN”,“address\_line\_1”:“171 Victoria Street”},“nationality”:“French”,“appointed\_on”:“2015-09-01”},{“officer\_role”:“director”,“links”:{“officer”:{“appointments”:"/officers/aRDye\_Q4OUqBZmCj1lMA267OL6E/appointments"},“self”:"/company/00233462/appointments/ZjC5C1MUnqyRLXe1LQm8sU-mtHQ"},“appointed\_on”:“2020-02-04”,“address”:{“country”:“United Kingdom”,“postal\_code”:“SW1E 5NN”,“premises”:“171”,“address\_line\_1”:“Victoria Street”,“locality”:“London”},“nationality”:“British”,“name”:“WHITE, Sharon Michele”,“occupation”:“Chairman”,“country\_of\_residence”:“United Kingdom”,“date\_of\_birth”:{“month”:4,“year”:1967}},{“address”:{“country”:“United Kingdom”,“locality”:“London”,“postal\_code”:“SW1E 5NN”,“address\_line\_1”:“Victoria Street”,“premises”:“171”},“appointed\_on”:“2021-06-07”,“links”:{“self”:"/company/00233462/appointments/HB4s5iJ8uYkZgWA1sX1ELWo3XSQ",“officer”:{“appointments”:"/officers/wn3Fdtsn3A9ijq38UlYa6WN4evw/appointments"}},“resigned\_on”:“2021-11-01”,“officer\_role”:“secretary”,“name”:“BLACKBURN, Simon Jim”},{“appointed\_on”:“2014-07-31”,“address”:{“postal\_code”:“SW1P 1BX”,“country”:“United Kingdom”,“address\_line\_1”:“Carlisle Place”,“locality”:“London”,“premises”:“Partnership House”},“officer\_role”:“secretary”,“name”:“BUCHANAN, Alan”,“resigned\_on”:“2015-01-31”,“links”:{“self”:"/company/00233462/appointments/8kRwOI3G3inceERcRv7gFYUlmFM",“officer”:{“appointments”:"/officers/6-79WOdAxM6z4dSKxJcJVDKCzW0/appointments"}}},{“name”:“CASELY-HAYFORD, Margaret Henrietta Augusta”,“officer\_role”:“secretary”,“links”:{“self”:"/company/00233462/appointments/wQl4eldhabK47WN7SbszTui\_OsE",“officer”:{“appointments”:"/officers/UjLuEeottNZYMxCY3gDpLs5-xbQ/appointments"}},“resigned\_on”:“2014-07-31”,“appointed\_on”:“2006-04-28”,“address”:{“address\_line\_1”:“171 Victoria Street”,“locality”:“London”,“postal\_code”:“SW1E 5NN”}},{“appointed\_on”:“2015-02-01”,“address”:{“postal\_code”:“SW1E 5NN”,“country”:“United Kingdom”,“premises”:“171”,“locality”:“London”,“address\_line\_1”:“Victoria Street”},“name”:“HUBBER, Keith Michael”,“officer\_role”:“secretary”,“links”:{“self”:"/company/00233462/appointments/Q0LteFCu-Syom10ioT9Dr1htCYI",“officer”:{“appointments”:"/officers/yJnxJaUKrL-9txGBFBdpxrusD\_U/appointments"}},“resigned\_on”:“2018-01-31”},{“appointed\_on”:“2001-05-10”,“address”:{“postal\_code”:“SW1E 5NN”,“locality”:“London”,“address\_line\_1”:“171 Victoria Street”},“name”:“NEVILLE, Terence Frank”,“officer\_role”:“secretary”,“links”:{“self”:"/company/00233462/appointments/CgEemxuQJE5mTi92xQ2oGshsYWQ",“officer”:{“appointments”:"/officers/R2yZiYHdGCIuUudWHaAsgRFxHtE/appointments"}},“resigned\_on”:“2006-04-27”},{“officer\_role”:“secretary”,“name”:“PRITCHARD, Brian James”,“resigned\_on”:“2001-05-09”,“links”:{“officer”:{“appointments”:"/officers/zTn1prjjtL12GNATDVGxlaSpDpU/appointments"},“self”:"/company/00233462/appointments/SiAJVi5yl8sfRL3TaHrXkvoQZiU"},“address”:{“address\_line\_1”:“The Chase, Garden Close Lane”,“address\_line\_2”:“Wash Common”,“locality”:“Newbury”,“postal\_code”:“RG14 6PP”,“region”:“Berkshire”}},{“address”:{“postal\_code”:“SW1E 5NN”,“locality”:“London”,“address\_line\_1”:“Victoria Street”,“premises”:“171”,“country”:“United Kingdom”},“appointed\_on”:“2018-01-31”,“links”:{“self”:"/company/00233462/appointments/VcwvWhG2isrR48Vfqlm\_GfL48Lc",“officer”:{“appointments”:"/officers/pFqcA4eqHE\_jFpF\_pRBpdg3jAe4/appointments"}},“resigned\_on”:“2021-06-07”,“name”:“SIMPSON, Peter”,“officer\_role”:“secretary”},{“links”:{“officer”:{“appointments”:"/officers/RY64rYPEaYutNFQUXeLVK94PVBo/appointments"},“self”:"/company/00233462/appointments/zIG-wRRzJPx8qpX2oRWhEJ6YIPA"},“resigned\_on”:“2005-11-27”,“officer\_role”:“director”,“address”:{“locality”:“London”,“postal\_code”:“SW1E 5NN”,“address\_line\_1”:“171 Victoria Street”},“nationality”:“British”,“appointed\_on”:“1993-07-22”,“date\_of\_birth”:{“month”:3,“year”:1950},“occupation”:“Director”,“name”:“ALEXANDER, Ian David”},{“occupation”:“Director Of Building & Svc”,“name”:“CARPENTER, John Barnard Grantley”,“date\_of\_birth”:{“month”:4,“year”:1936},“officer\_role”:“director”,“resigned\_on”:“1999-12-24”,“links”:{“officer”:{“appointments”:"/officers/GKVoR4S0RRA31V5ovI9dXS9Mgp8/appointments"},“self”:"/company/00233462/appointments/zW4w34gwzYShnMcTjnvB-CC-LFs"},“nationality”:“British”,“address”:{“postal\_code”:“N1 2PB”,“address\_line\_1”:“Flat 4”,“address\_line\_2”:“50 Compton Road”,“locality”:“London”}},{“name”:“CASSONI, Marisa Luisa”,“occupation”:“Director”,“date\_of\_birth”:{“month”:12,“year”:1951},“country\_of\_residence”:“United Kingdom”,“officer\_role”:“director”,“resigned\_on”:“2012-06-01”,“links”:{“self”:"/company/00233462/appointments/mqpTYB2vpRVr4s85fKFn9OFIcxo",“officer”:{“appointments”:"/officers/mfKR\_kFIwUX\_074RQmkcFPDXE7E/appointments"}},“appointed\_on”:“2006-07-20”,“nationality”:“British”,“address”:{“address\_line\_1”:“Victoria Street”,“premises”:“171”,“country”:“United Kingdom”,“locality”:“London”,“postal\_code”:“SW1E 5NN”}},{“officer\_role”:“director”,“resigned\_on”:“2002-12-30”,“links”:{“self”:"/company/00233462/appointments/kGpGTGSwCkieJJqUDqEnxc9Xuwc",“officer”:{“appointments”:"/officers/7u04zPDUB02c374UaOxIet-YQ7s/appointments"}},“nationality”:“British”,“address”:{“postal\_code”:“SE16 5ES”,“address\_line\_1”:“Flat 40 Canada Wharf”,“address\_line\_2”:“255 Rotherhithe Street”,“locality”:“London”},“occupation”:“Director”,“name”:“CLOAKE, Dudley Richard”,“date\_of\_birth”:{“month”:10,“year”:1943}},{“officer\_role”:“director”,“resigned\_on”:“2007-04-24”,“links”:{“self”:"/company/00233462/appointments/OOI7ORQqc5Eqa\_E0zNUycPoxKrg",“officer”:{“appointments”:"/officers/Y7pkx0D7O4Ii7Bri\_UHSxRFQ2Vk/appointments"}},“appointed\_on”:“2002-03-11”,“address”:{“address\_line\_1”:“171 Victoria Street”,“postal\_code”:“SW1E 5NN”,“locality”:“London”},“nationality”:“British”,“name”:“ESOM, Steven Derek”,“occupation”:“Director”,“date\_of\_birth”:{“year”:1960,“month”:11}},{“name”:“FALCONER, Peter”,“occupation”:“Dir Of Buying Waitrose”,“date\_of\_birth”:{“year”:1936,“month”:6},“nationality”:“British”,“address”:{“region”:“Buckinghamshire”,“postal\_code”:“HP9 2LS”,“address\_line\_1”:“Pennfields Penn Road”,“locality”:“Beaconsfield”},“officer\_role”:“director”,“resigned\_on”:“1996-06-20”,“links”:{“officer”:{“appointments”:"/officers/5QfusxJUs8tjNdktA8-eFh\_4KR4/appointments"},“self”:"/company/00233462/appointments/cmuIKMt5e7hHU3ZqOO5n8fNHNgc"}},{“occupation”:“Director”,“name”:“FELWICK, David Leonard”,“country\_of\_residence”:“United Kingdom”,“date\_of\_birth”:{“month”:11,“year”:1944},“officer\_role”:“director”,“resigned\_on”:“2004-09-03”,“links”:{“self”:"/company/00233462/appointments/xEw7wzqvPXVerBD5zBBlSHrHClg",“officer”:{“appointments”:"/officers/IGR0tRIrEJLe9aOqpq6HKK0YQvg/appointments"}},“address”:{“address\_line\_1”:“171 Victoria Street”,“locality”:“London”,“postal\_code”:“SW1E 5NN”},“nationality”:“British”},{“date\_of\_birth”:{“year”:1963,“month”:4},“country\_of\_residence”:“United Kingdom”,“name”:“FLEMING, Ian Ashley”,“occupation”:“Corporate Treasurer”,“links”:{“self”:"/company/00233462/appointments/lX3ZnecXIYk40\_fxXFG4wCNwkuQ",“officer”:{“appointments”:"/officers/qz\_s\_XofN-6uI3M0dJ2\_ky-tMk8/appointments"}},“resigned\_on”:“2014-08-15”,“officer\_role”:“director”,“address”:{“address\_line\_1”:“Victoria Street”,“postal\_code”:“SW1E 5NN”,“country”:“England”,“premises”:“171”,“locality”:“London”},“nationality”:“British”,“appointed\_on”:“2013-01-23”},{“occupation”:“Director Of Buying”,“name”:“FLETCHER, Leslie Herbert”,“date\_of\_birth”:{“year”:1934,“month”:12},“officer\_role”:“director”,“resigned\_on”:“1993-07-22”,“links”:{“self”:"/company/00233462/appointments/IdhgBzeU4XDTZ7KfIFo9S\_XFXO4",“officer”:{“appointments”:"/officers/q8rUfTg9ReOWQ42Fxj\_985U7kek/appointments"}},“address”:{“locality”:“London”,“postal\_code”:“W9 1DR”,“address\_line\_1”:“26 Randolph Crescent”,“address\_line\_2”:“Maida Vale”},“nationality”:“British”},{“date\_of\_birth”:{“month”:1,“year”:1947},“name”:“HAMPSON, Stuart”,“occupation”:“Chairman”,“address”:{“postal\_code”:“SW1E 5NN”,“address\_line\_1”:“171 Victoria Street”,“locality”:“London”},“nationality”:“British”,“resigned\_on”:“2007-04-01”,“links”:{“officer”:{“appointments”:"/officers/SyyN7PxI8QQUZrvehg0-EizSUOU/appointments"},“self”:"/company/00233462/appointments/WfJlzcsZy9MafymMxVr9E32zaZ8"},“officer\_role”:“director”},{“country\_of\_residence”:“United Kingdom”,“date\_of\_birth”:{“month”:4,“year”:1951},“occupation”:“Alternate Director”,“name”:“HAUFF, Reyn”,“nationality”:“British”,“address”:{“postal\_code”:“SW1E 5NN”,“address\_line\_1”:“171 Victoria Street”,“address\_line\_2”:“London”},“appointed\_on”:“2009-12-15”,“resigned\_on”:“2015-01-27”,“links”:{“officer”:{“appointments”:"/officers/omUi4DNkWt4QIRW1kL\_f0pUN7RM/appointments"},“self”:"/company/00233462/appointments/pd3hA\_x\_mShgFI9Bg1kHjprOqpo"},“officer\_role”:“director”},{“name”:“KILLEN, Tracey Anne”,“occupation”:“Director”,“date\_of\_birth”:{“year”:1961,“month”:4},“officer\_role”:“director”,“resigned\_on”:“2020-07-10”,“links”:{“officer”:{“appointments”:"/officers/dtPbNs3Lol4aKeZsqfPAkQ9avO8/appointments"},“self”:"/company/00233462/appointments/0UK92WHgEwT4S9vizIE8rqvSg70"},“appointed\_on”:“2007-04-30”,“address”:{“postal\_code”:“SW1E 5NN”,“locality”:“London”,“address\_line\_1”:“171 Victoria Street”},“nationality”:“British”},{“date\_of\_birth”:{“month”:7,“year”:1965},“country\_of\_residence”:“England”,“name”:“LEWIS, John Patrick”,“occupation”:“Retailer”,“address”:{“address\_line\_2”:“London”,“address\_line\_1”:“171 Victoria Street”,“postal\_code”:“SW1E 5NN”},“nationality”:“British”,“appointed\_on”:“2015-09-14”,“resigned\_on”:“2020-12-31”,“links”:{“officer”:{“appointments”:"/officers/6Q-pEybtm-yGmGJFk3txQCDKKRA/appointments"},“self”:"/company/00233462/appointments/TqXPzq3XC3CXcjGcfSFzXAZSDtY"},“officer\_role”:“director”},{“name”:“LEWIS, Peter Tyndale”,“occupation”:“Chairman”,“date\_of\_birth”:{“month”:9,“year”:1929},“nationality”:“British”,“address”:{“postal\_code”:“W8 5RA”,“locality”:“London”,“address\_line\_1”:“Flat No 1-34 Victoria Road”},“officer\_role”:“director”,“links”:{“self”:"/company/00233462/appointments/aag-sfAcOvD-Dd-B6W7QgI6DJis",“officer”:{“appointments”:"/officers/ukkfNL-7vob5On-Hb\_SMMZA7if4/appointments"}},“resigned\_on”:“1993-02-01”},{“name”:“MAYFIELD, Andrew Charles, Sir”,“occupation”:“Director”,“country\_of\_residence”:“United Kingdom”,“date\_of\_birth”:{“year”:1966,“month”:12},“appointed\_on”:“2001-09-24”,“address”:{“address\_line\_1”:“171 Victoria Street”,“locality”:“London”,“postal\_code”:“SW1E 5NN”},“nationality”:“British”,“officer\_role”:“director”,“links”:{“self”:"/company/00233462/appointments/OlBpEAcID9UDPXIG-r25PRw4sOc",“officer”:{“appointments”:"/officers/nY4vtPx5\_W\_TFSFr9ZHZK2AvzYE/appointments"}},“resigned\_on”:“2020-02-04”},{“occupation”:“Director”,“name”:“MAYHEW, Christopher Luke”,“date\_of\_birth”:{“month”:6,“year”:1953},“appointed\_on”:“1993-07-22”,“address”:{“postal\_code”:“SW1E 5NN”,“address\_line\_1”:“171 Victoria Street”,“locality”:“London”},“nationality”:“British And New Zealand”,“officer\_role”:“director”,“links”:{“self”:"/company/00233462/appointments/7zhAi72Q7yqLCYcjA2lzIo2bExA",“officer”:{“appointments”:"/officers/0nCJIzMpj-a31CprpQYzXcJt5rM/appointments"}},“resigned\_on”:“2004-12-24”},{“occupation”:“Alternate Director”,“name”:“MICHEL, Berangere Andree Mireille”,“date\_of\_birth”:{“month”:11,“year”:1973},“country\_of\_residence”:“England”,“appointed\_on”:“2009-12-15”,“address”:{“address\_line\_2”:“London”,“address\_line\_1”:“171 Victoria Street”,“postal\_code”:“SW1E 5NN”},“nationality”:“French”,“officer\_role”:“director”,“links”:{“self”:"/company/00233462/appointments/QhBfTLMMyV3BOMNVhpUeYXfhkQc",“officer”:{“appointments”:"/officers/9215jCvRXjjcnqAxDJX6G7WOYjc/appointments"}},“resigned\_on”:“2015-01-27”},{“appointed\_on”:“2017-01-11”,“nationality”:“British”,“address”:{“postal\_code”:“SW1E 5NN”,“country”:“United Kingdom”,“locality”:“London”,“address\_line\_1”:“Victoria Street”,“premises”:“171”},“officer\_role”:“director”,“resigned\_on”:“2020-01-23”,“links”:{“officer”:{“appointments”:"/officers/TwWlcETK6LItT8ItaFPIWBmO300/appointments"},“self”:"/company/00233462/appointments/BhPtrUrB9ULmPWIzNykPuzUd60s"},“name”:“NICKOLDS, Paula Margaret”,“occupation”:“Retail Buyer”,“date\_of\_birth”:{“year”:1973,“month”:2},“country\_of\_residence”:“United Kingdom”},{“officer\_role”:“director”,“links”:{“self”:"/company/00233462/appointments/iqHmTD-CwuC1h45CFK6OKivkaZc",“officer”:{“appointments”:"/officers/kwYpFR6DRLbKZ5lKEyu\_lcjm8jo/appointments"}},“resigned\_on”:“2000-01-28”,“nationality”:“British”,“address”:{“locality”:“Clifton”,“postal\_code”:“SG17 5EQ”,“region”:“Bedfordshire”,“address\_line\_1”:“2 Clifton House Close”},“occupation”:“Director Of Trading (Ds)”,“name”:“O’CALLAGHAN, Brian Anthony”,“date\_of\_birth”:{“year”:1942,“month”:6}},{“resigned\_on”:“1993-09-09”,“links”:{“officer”:{“appointments”:"/officers/\_rAzQsjw0g4twigk043K-1SDwWE/appointments"},“self”:"/company/00233462/appointments/\_tSp6RfAW2F\_InIvrm98vUhnY-s"},“officer\_role”:“director”,“address”:{“region”:“Surrey”,“postal\_code”:“KT1 2TL”,“locality”:“Kingston Upon Thames”,“address\_line\_1”:“19 Lingfield Avenue”},“nationality”:“British”,“date\_of\_birth”:{“year”:1937,“month”:11},“occupation”:“Managing Director Of Store”,“name”:“ORYAN, Peter Jerome Francis”},{“resigned\_on”:“2015-08-31”,“links”:{“self”:"/company/00233462/appointments/Cs7XzKocUp\_A6HmPAjNsPnUox\_w",“officer”:{“appointments”:"/officers/h6xlBnvtjnhKmSNxbYkAql8MYKM/appointments"}},“officer\_role”:“director”,“address”:{“premises”:“171”,“postal\_code”:“SW1E 5NN”,“country”:“England”,“locality”:“London”,“address\_line\_1”:“Victoria Street”},“nationality”:“British”,“appointed\_on”:“2013-01-23”,“date\_of\_birth”:{“month”:3,“year”:1965},“country\_of\_residence”:“United Kingdom”,“occupation”:“Finance Director”,“name”:“OSBORNE, Rachel Claire Elizabeth”},{“links”:{“self”:"/company/00233462/appointments/X3qOK2-YZ8xUCYstfSrz3gAIGmM",“officer”:{“appointments”:"/officers/PBkZA2r7wAiDaG83DKUa73f03gc/appointments"}},“resigned\_on”:“2016-03-18”,“officer\_role”:“director”,“nationality”:“British”,“address”:{“address\_line\_1”:“171 Victoria Street”,“locality”:“London”,“postal\_code”:“SW1E 5NN”},“appointed\_on”:“2005-01-30”,“date\_of\_birth”:{“year”:1961,“month”:3},“country\_of\_residence”:“United Kingdom”,“name”:“PRICE, Mark Ian”,“occupation”:“Director”},{“nationality”:“British”,“address”:{“postal\_code”:“SW15 6UQ”,“locality”:“London”,“address\_line\_1”:“9 Woodthorpe Road”},“resigned\_on”:“1993-07-22”,“links”:{“officer”:{“appointments”:"/officers/pWfMm6kvGhTlge1nP83FmEoj55U/appointments"},“self”:"/company/00233462/appointments/appCG1rSqNXXdAkswUMmHtiLFl0"},“officer\_role”:“director”,“date\_of\_birth”:{“month”:7,“year”:1933},“occupation”:“Director Of Buying”,“name”:“QUINN, Jean Margaret”},{“name”:“STILL, Peter Walker Kenneth”,“occupation”:“Managing Director Of Store”,“date\_of\_birth”:{“month”:1,“year”:1948},“nationality”:“British”,“address”:{“address\_line\_1”:“Clavering Darkes Lane”,“locality”:“Potters Bar”,“postal\_code”:“EN6 1DB”,“region”:“Hertfordshire”},“officer\_role”:“director”,“links”:{“officer”:{“appointments”:"/officers/fI1KnbIk7P4P8058jgtI-C964gI/appointments"},“self”:"/company/00233462/appointments/wYaI1PpbWhn3owF30D6zSHNXU1s"},“resigned\_on”:“1993-09-09”},{“links”:{“officer”:{“appointments”:"/officers/dRaTsmSngmqooL38YT7135jT0mw/appointments"},“self”:"/company/00233462/appointments/a6hUKlhtvwqn-cuUf1Lkw5i0p\_o"},“resigned\_on”:“2016-10-28”,“officer\_role”:“director”,“address”:{“locality”:“London”,“address\_line\_1”:“171 Victoria Street”,“postal\_code”:“SW1E 5NN”},“nationality”:“British”,“appointed\_on”:“2002-12-30”,“country\_of\_residence”:“United Kingdom”,“date\_of\_birth”:{“month”:6,“year”:1963},“occupation”:“Director”,“name”:“STREET, Andrew John”}],“active\_count”:3,“inactive\_count”:0,“items\_per\_page”:35,“etag”:“91446922a23f342c7af4a4753767c41f4c3ca339”,“resigned\_count”:39,“kind”:“officer-list”,“start\_index”:0,“links”:{“self”:"/company/00233462/officers"},“total\_results”:42},“responseHeader”:{“date”:“Thu, 16 Mar 2023 16:12:01 GMT”,“content-length”:“16517”,“server”:“CompaniesHouse”,“x-ratelimit-limit”:“600”,“access-control-allow-headers”:“X-RateLimit-Query, origin, content-type, content-length, user-agent, host, accept, authorization”,“x-ratelimit-reset”:“1678983369”,“pragma”:“no-cache”,“access-control-expose-headers”:“Location,www-authenticate,cache-control,pragma,content-type,expires,last-modified”,“access-control-allow-credentials”:“true”,“access-control-max-age”:“3600”,“content-type”:“application/json”,“connection”:“keep-alive”,“x-ratelimit-remain”:“598”,“cache-control”:“no-store, no-cache, must-revalidate, post-check=0, pre-check=0”,“x-ratelimit-window”:“5m”},“responseCode”:200}"

//output

- “3”
- “null,null,null”"

---

<div class="post-metadata">

**Author:** ![voracityemail](http://forum.companieshouse.gov.uk/letter_avatar_proxy/v4/letter/v/b77776/32.png) [@voracityemail](http://forum.companieshouse.gov.uk/u/voracityemail)\
**Post date:** [March 16, 2023, 6:14pm UTC](http://forum.companieshouse.gov.uk/t/extracting-director-data-from-json/6040/2 "2023-03-16T18:14:36Z")

</div>

It’s not really a query for here, and I don’t speak your language (Deluge)… but …

> [@liamcooke.jones](#):
>
> NumberOfOfficers = response.get(“active\_count”);  
> info NumberOfOfficers;  
> nameList = Collection();  
> for each NumberOfOfficers in response  
> {  
> nameList.insert(response.getjson(“links:/items:/name”));  
> }  
> info nameList;  
> }

EDIT: the `Response` you list is indeed that from [Deluge’s invokeURL task](https://www.zoho.com/deluge/help/webhook/invokeurl-api-task.html) by the looks of it. The whole `Response` is not “JSON”. It’s a something (map? Collection? I don’t know what Deluge calls objects or this kind of object) which stores the response in the `responseText` member. It’s not clear from this whether the `responseText` field here contains JSON _already parsed_ to key-value pairs (however Deluge describes this e.g. a map etc.) or whether this is indeed just a long string. This doesn’t really make any difference to what I’ve written below though!

`Response` contains:

```
"responseText": ... // (either a string OR key - value pairs, where the values may possibly be further maps)
"responseHeader": { }, // contains key-value pairs with the http response header
"responseCode": 200

```

END EDIT

1. what is `response`? What type does it have? The [API says it returns the structure given in this link](https://developer-specs.company-information.service.gov.uk/companies-house-public-data-api/resources/officerlist?v=latest). [The Deluge manual says a response can be text, or key-value pairs, or a list](https://www.zoho.com/deluge/help/webhook/invokeurl-api-task.html).

2. When you use `for each` what are you iterating over? (if you can do response.get(“active\_count”), I’d expect this to iterate over all the values in `response` - but I don’t know Deluge.) I’d expect `response` here to be a map (has key-\>value pairs) rather than a list - with one of the keys being `items` which should contain a _list_ of Officer resources. I suspect you want to iterate over each officer in the list within response, no?

Then - why are you (apparently) assigning something to `NumberOfOfficers` on each loop and then not using that? I would expect you to be using the variable here (or rather one with a more accurate title like `officerItem`) as `officerItem`.

Then - what is `response.getjson(“links:/items:/name”));` ? Is there any such map here with structure `links -> items -> name` ? (Hint - clearly not where you are looking as you’re getting a null! Where is this links → items? You’ll find links → self at one level and links → officer and links → self in each officer item…)

What would something like the following do?

```
for each OfficerItem in response.get("items")
{
nameList.insert(OfficerItem.get("name")); // or whatever the syntax is to access the name member of Officeritem - assuming response.get("items") returns a map / collection
}

```

The language reference seems to say that [getJson works on a JSON string or a Collection (key-value pairs?)](https://www.zoho.com/deluge/help/functions/common/getjson.html)
