VMware Aria Automation Orchestrator

 View Only

 JSON.parse and Special Character

Jump to  Best Answer
SistDip's profile image
SistDip posted Feb 16, 2026 06:11 AM

Hello mates,

I'm stucked with JSON.parse that failed to manage special character in the name of the field retrieved, I'll try to better explain :

Postman answer:

    "entries": [
        {
            "values": {
                "Asset ID+": "A546",
                "Name": "Enterprise Architecture Platform",
                "RTO": ">24"
            },
            "_links": {
                "self": [
                    {
                        "href": "https://itam/AST:Application/000000000000202%7C000000000000201%7C000000000127895%7C00000000001703"
                    }
                ]
            }
        }
]

I need to print out the field Asset ID+, Name and RTO ... no problem with Name and RTO but how I can index the first field that has spaces and special char in the colum name? My code fails : 

var cmdbRequest = restHost.createRequest("GET", applUrl);
cmdbRequest.setHeader("Content-Type", "application/json");
cmdbRequest.setHeader("Authorization", token);

try {
    var response = cmdbRequest.execute();
    //logger.info("Status code: " + response.statusCode);
    if (!(response.statusCode >= 200 && response.statusCode <= 204)) {
        throw  "HTTP " + response.statusCode + " : " + response.contentAsString;
    }

    var result = JSON.parse(response.contentAsString);
    for each (row in result.entries) {
        System.log(row.values.Name);
        System.log(row.values.Asset%20ID%2B);
    }

} catch (e) {
    logger.error ("Could not retrieve ApplID from CMDB : " + e);
    throw ("Could not retrieve ApplID from CMDB : " + e);
}

I tryed with :

  • row.values.Asset%20ID%2B
  • row.values.'Asset%20ID%2B'
  • row.values."Asset ID+"
  • - row.values.'Asset ID+'

Could someone help me with this colum? I cannot change the name of the field in the source

Cheers

Alberto Cangani's profile image
Broadcom Employee Alberto Cangani  Best Answer

you can access to that value with the square brackets, like an array

System.log(row.values["Asset ID+"])
Deyan Boikliev's profile image
Broadcom Employee Deyan Boikliev

Hello,
When a property contains special characters you need to use the bracket notation, e.g. row.Values["Asset ID+"].

SistDip's profile image
SistDip

U saved my day! Thanks!