Json returning result in brackets

Hi, this is probably a stupid question and I have tried to find the solution for quite a while now. Im trying to get a specific parameter from an API. I get the parameter but it’s in brackets: [XXXXX]. How to I get the parameter to show without brackets? Thank you in advance.

def getSystemId() {
def params = [
    uri:  'https://api.nibeuplink.com',
    path: '/api/v1/systems',
    contentType: 'application/json',
    headers: ["Authorization": "Bearer ${atomicState.authToken}"]
try {
    httpGet(params) {resp ->
        log.debug "resp data: ${resp.data}"
        log.debug "systemId: ${resp.data.objects.systemId}"

		return resp.data.objects.systemId	
} catch (e) {
    log.error "error: $e"


Just found a way, don’t know if it’s the easiest but i used the string feature from the Groovy basics guide.

def systemId = resp.data.objects.systemId.toString() - "]" - "["	
return systemId

Just put [0] at the end this should return the first entry…

E.g. systemId[0]

Yes! Thank you:)

1 Like

No worries took me a while to discover that one too!

1 Like