As I delve into the world of JSON and REST, I find myself testing a REST API that returns strings in the following format:
[{
"Supervisor_UniqueName": "adavis",
"Active": "true",
"DefaultCurrency_UniqueName": "USD",
"arches_type": "x-zensar/primary",
"Groups": "",
"TimeZoneID": "US/Pacific-New",
"UniqueName": "!!pl-10958-611879240",
"EmailAddress": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4d6c6c3d21607c7d747875607b7c7c757a747f797d0d29283b202c2421633728233e2c3f632e2220">[email protected]</a>",
"LocaleID_UniqueName": "en_US",
"Name": "!!pl-10958-611879240"
}, {
"Supervisor_UniqueName": "adavis",
"Active": "true",
"DefaultCurrency_UniqueName": "USD",
"arches_type": "x-zensar/primary",
"Groups": "",
"TimeZoneID": "US/Pacific-New",
"UniqueName": "!!pl-10958-789764779",
"EmailAddress": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="fddcdc8d91d0cccdc4c8c5d0cac5c4cacbc9cacac4bd99988b909c9491d38798938e9c8fd39e9290">[email protected]</a>",
"LocaleID_UniqueName": "en_US",
"Name": "!!pl-10958-789764779"
}, {
"Supervisor_UniqueName": "adavis",
"Active": "true",
"DefaultCurrency_UniqueName": "USD",
"arches_type": "x-zensar/primary",
"Groups": "Report User",
"TimeZoneID": "US/Pacific-New",
"UniqueName": "105838945",
"EmailAddress": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="eadbdadfd2d9d2d3dedfaa8e8f9c878b8386c4908f84998b98c4898587">[email protected]</a>",
"LocaleID_UniqueName": "en_US",
"Name": "105838945"
}, {
"Supervisor_UniqueName": "adavis",
"Active": "true",
"DefaultCurrency_UniqueName": "USD",
"arches_type": "x-zensar/primary",
"Groups": "Report User, Report Manager, Report Administrator",
"TimeZoneID": "US/Pacific-New",
"UniqueName": "112352755",
"EmailAddress": "<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="72434340414740454747321617041f131b1e5c08171c0113005c111d1f">[email protected]</a>",
"LocaleID_UniqueName": "en_US",
"Name": "112352755"
}]
I make a call to the REST API like this:
final ResponseEntity<String> responseEntity = restTemplate.getForEntity(resourceUrl , String.class);
where restTemplate
is an instance of type RestTemplate
My goal is to convert these strings into a JSON array, iterate through each JSON object, and retrieve the field and values for each one.
Can jackson help achieve this functionality?