function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
APathakAPathak 

Generate Json String in apex controller

Hi,

I want to generate a JSON string that wil be used in the page. So i wrote a javascript remote action method which returns the JSON string. 

The problem is this :-

In apex debug the json string comes perfect :

 

'[{ "label": "CTS Test Self", "value": "CTS Test Self"},{ "label": "test", "value": "test"}]'

 

But in chrome debug i am seeing the distored JSON string :-

 

'[{ "label": "CTS Test Self", "value": "CTS Test Self"},{ "label": "test", "value": "test"}]'

 

Due to this the json string is not getting converted into json object.

Please help.

sfdcfoxsfdcfox

From what I can tell, it looks like you need to unescape it (see https://developer.mozilla.org/en-US/docs/DOM/window.unescape, http://www.w3schools.com/jsref/jsref_unescape.asp, et al).