- 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:37 AM
Abhishek,
But i want the output in Object. but i am getting as shown below:
*** Script: Users Details:0. firstname
*** Script: Users Details:1. lastname
*** Script: Users Details:2. fullname
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2019 07:40 AM
Hello Irfan,
Do you want it JSON Object or what else?
Thanks,
Abhishek
Abhishek Gardade
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2019 07:42 AM
You can refer below code as well:
Example
var obj = {“name":"George","lastname":"Washington"};
var str = JSON.stringify(obj);
gs.info(‘The object ’ + str);
Output
The object {"name":"George","lastname":"Washington"}
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:52 AM
Yes i want in JSOB object. I want the output as below
{
"Users Details:0." : "firstname",
"Users Details:1." : "lastname",
"Users Details:2." : "fullname"
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-08-2019 07:58 AM
Chcek out this code:
var obj = {“name":"George","lastname":"Washington"};
var str = JSON.stringify(obj);
gs.info(‘The object ’ + str);
Please mark as Correct Answer/Helpful, if applicable.
Thanks!
Abhishek Gardade
Abhishek Gardade