- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2019 07:00 AM
Hi,
I am getting a String data as below which i want to convert into Object
String = firstname, lastname, fullname
which i want to convert to an object can anyone please help me on this
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2019 07:31 AM
Hello Irfan,
Check out the code:
var str = 'firstname, lastname, fullname';
var arr = str.split(',');
for(i=0; i<arr.length; i++){
gs.print('Users Details:'+i+". "+ arr[i]);
}
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Abhishek Gardade

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2019 07:03 AM
Here is the sample
var str = 'firstname, lastname, fullname'
var arr = str.split(',')
var obj = {};
obj.first_name = str[0];
obj.last_name = str[1];
obj.full_name = str[2];
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2019 07:14 AM
Thank you.
But the problem is we are not sure how many words we may get in String field. instead of hardcoding he obj names can we set dynamically

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2019 07:30 AM
Can you provide more details
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2019 07:31 AM
Hello Irfan,
Check out the code:
var str = 'firstname, lastname, fullname';
var arr = str.split(',');
for(i=0; i<arr.length; i++){
gs.print('Users Details:'+i+". "+ arr[i]);
}
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Abhishek Gardade