Wednesday 8 July 2015

JSON Parse Error - Unexpected Token

Hi Floks ,


When we are trying to parse the data , which are coming from Apex ,some time we may experience the following issue,

      JSON Parse Error - Unexpected Token

Code snippet :


     Var JSONVal = '{!StrJONdata}' // Apex string using to parse the data.     var ParsedData = JSON.parse(JSONVal );


In the above scenario , some times you may experince above error.Please use JSENCODE tag to format the string ,


Code snippet :


var JSEncode = '{!JSENCODE(strJSON)}';var lstVOCQustns = JSON.parse(JSEncode);


Thanks 

No comments:

Post a Comment