How to remove slash from encoded json object

Raju Lakkam
Mega Contributor

Hi All,

I created one custom UI page. I got bunch of key value pair data in my object( for example categories). In client script I am creating chart using highchart. I need to pass the object to client script to get chart, but I am getting error while encode the object(in console). Every key and value encode with slash.

find_real_file.png

please guide me how to remove slash from this object.

Thank you in advance.

 

3 REPLIES 3

Brad Bowman
Kilo Patron
Kilo Patron

I have seen this when I parsed an object that was already recognized as JSON.  What are you getting for the value of the object in the client script - not in this function?

Hi Brad,

Thank you for your reply,

I am not getting any response in client script. Before call drawAllchartts() function As shown in image I got stuck.

Hemanth M1
Giga Sage
Giga Sage

Hi Raju,

if its a encoded JSON ---convert that to string---> var str = JSON.stringify(categories);

Replace slash everywhere in the string----------->str =str.replace(/\//g,"");

You can convert back to JSON object again using-->var output =JSON.parse(str);

 

 

 Mark it as correct or helpful if it helps.

Accept and hit Helpful if it helps.

Thank you,
Hemanth
Certified Technical Architect (CTA), ServiceNow MVP 2024, 2025