jQuery.parseJSON vs JSON.parse

后端 未结 7 1298
感情败类
感情败类 2020-11-27 06:29

jQuery.parseJSON and JSON.parse are two functions that perform the same task. If the jQuery library is already loaded, would using jQuery.parseJSON be better th

7条回答
  •  醉话见心
    2020-11-27 06:56

    JSON.parse() is natively available on some browsers, not on others, so it's safer to use a library. The JQuery implementation works well, as other respondents have noted. There's also Douglas Crockford's JSON library, which uses the native implementation if available.

    The JSON library has the advantage that it has a method to turn a JavaScript object into a JSON string, which is missing from jQuery at the moment..

提交回复
热议问题