Webgangster
Contributor
Contributor

vRO Action - JSON output with - in the field

Jump to solution

Hi guys,

I'm working to make a vRO Action that receive data from our CMDB with API.

Some on the field in the CMDB contains the '-' character, like 'mac-adres'.

 

This is my code:

var res = JSON.parse(response.contentAsString);
var output = res.data.mac-adres
return output

 It is not working: ReferenceError: "adres" is not defined.

If i test it with data witout '-', it is working. 

 

How do i fix this? I want to return the mac-adres data 🙂

 

Thank you.

 

Stefan

0 Kudos
1 Solution

Accepted Solutions
eoinbyrne
Expert
Expert

Hi

You can access the data you want by using the following style to retrieve it

var output = res.data["mac-adres"];

-HTH

View solution in original post

1 Reply
eoinbyrne
Expert
Expert

Hi

You can access the data you want by using the following style to retrieve it

var output = res.data["mac-adres"];

-HTH