Array & string in rest message
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2023 05:11 AM
Hi all,
Can anyone please tell me on how to convert this into exact output as shown in image:
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!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2023 05:33 AM
Hello @shalani r ,
I am not sure what you are trying to do here, but in the second picture you are showing a JSON and in the first picture this.org is a string type, have you tried to JSON.parse() or JSON.stringify(), depending on what your final goal is.
Hope that this helps you!
If the provided information answers your question, please consider marking it as Helpful and Accepting the Solution so other community users can find it faster.
All the Best,
Stefan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2023 09:51 PM
Hello @Stefan Georgiev ,
Thanks for your response.
1st image is the script which i'm using and 2nd image is the expected result.
FYI.
Regards,
Shalani R
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2023 11:04 PM
Hello @shalani r,
yes after the split(',') you need to JSON.stringify() it, but if you want the same result as in the second picture you need to
var orgArr = allOrg.split(',')
var objToJSON = {organizations: orgArr }
var jsonObj = JSON.stringify(objToJSON )
gs.info(jsonObj)
But I am not sure what is your final goal and why you need it, you want to reuse some REST message logic you have or something?
Hope that this helps you!
If the provided information answers your question, please consider marking it as Helpful and Accepting the Solution so other community users can find it faster.
All the Best,
Stefan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-12-2023 11:18 PM
Thanks for your response.
I wanted the same result as shown in second image but it should be of array format.
Thanks in advance!