Array & string in rest message

shalani r
Tera Contributor

Hi all,

     Can anyone please tell me on how to convert this into exact output as shown in image:

shalanir_0-1702386297149.png

 

shalanir_4-1702386568903.png

after split its not separated as double quotes with comma its working as M-23AL,M-35HM

so kindly request to help with this.

 

Thanks in advance!

 

10 REPLIES 10

Sandeep Rajput
Tera Patron
Tera Patron

@shalani r Use the following.

 

this.org = JSON.stringify(allOrg);
gs.info(this.org); //Will print the allOrg in the format you shared.

Thanks for your response @Sandeep Rajput 

After split i need to do JSON.stringify() ?

 

Regards,

Shalani R

@shalani r No need for using split. Just use 

this.org = JSON.stringify(allOrg);

Thanks for your response.

Its not working because the values from list collector variable if multiple values are selected its taking as single string.

For eg: If I select abc nd def - its taking as "abc,def"

but i need it as "abc", "def"

this is the issue i'm facing here.

 

Thanks in advance!

@shalani r List collector stores a comma separated string of elements. In this case you can use 

 

this.org = JSON.stringify(allOrg.split(','));
gs.info(this.org);