I tried to detect JSON support with if(JSON.parse) {} but it doesn’t works. Is there any way to detect the JSON support?
I tried to detect JSON support with if(JSON.parse) {} but it doesn’t works. Is
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Taken from the json most famous implementation https://github.com/douglascrockford/JSON-js/blob/master/json2.js
(I have merged the two
if:if (!JSON) {of line 163 andif (typeof JSON.parse !== 'function') {of line 406.The trick here is that the
var JSONwill get the value of the JSON object of the browser,undefinedif not.Note that in the latest version of the library they changed the code to something like:
(without pre-declaring the
var JSON)