- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2019 07:32 AM
Hi,
I have String value which i want to convert as Object.
string = "user firstname" : "first name", "user lastname" :"last name", "user fullname" :"full name"
I want to convert this string into an object. Challenge is we may lot many values in String field which we are not sure so how to set them into 1 object dynamically
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2019 07:38 AM
Hi Shaik,
that seems to me like a json object;
store that in json rather than string
var jsonObj = {"user firstname":"first name","user lastname":"last name","user fullname":"full name"};
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2019 07:36 AM
check this out
Hope this helps.
Mark my ANSWER as CORRECT n HELPFUL if it helped.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2019 07:37 AM
Hi,
You would use JSON parse, like so:
var obj = JSON.parse('{ "name":"John", "age":30, "city":"New York"}');
This converts the text in to an object, which can then be used like...
document.getElementById("demo").innerHTML = obj.name + ", " + obj.age;
See link for more info: https://www.w3schools.com/js/js_json_parse.asp
Please mark reply as Helpful/Correct. Thanks!
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2019 08:24 AM
Haha, ok...
Glad you got your answer.
Take care
Please consider marking my reply as Helpful and/or Accept Solution, if applicable. Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-08-2019 07:38 AM
Hi Shaik,
that seems to me like a json object;
store that in json rather than string
var jsonObj = {"user firstname":"first name","user lastname":"last name","user fullname":"full name"};
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader