I have javascript object which i need to convert into string.
var obj = {"name": "XXX", "age": "27"};
After googling i have got JSON.stringify(obj);
JSON.stringify(obj);
is working fine if IE8 modes are same as below
Browser Mode : IE8
Documentn Mode: IE8 Standards
and the same code is not working If
Browser Mode : IE8
Documentn Mode: Quirks Mode
I am wondering why same thing is not working...
any idea will be appreciated.
I would recommend using
JSON.stringify
if you can fixed IE modes to IE8 and IE8 standards.JSON.stringify
will serializes an object and very easy to use. Most modern browsers support this method natively, but for those that don't, you can include a JS versionand If you can not fixed your IE modes then use below method to convert object to string.
Function:
Call a function:
Output: