Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve jQuery.parseJSON deprecation #260

Closed
jrun opened this issue Oct 5, 2018 · 2 comments
Closed

Resolve jQuery.parseJSON deprecation #260

jrun opened this issue Oct 5, 2018 · 2 comments

Comments

@jrun
Copy link

jrun commented Oct 5, 2018

jQuery.parseJSON is deprecated in favor of JSON.parse. Does it make sense to move to JSON.parse?

JQMIGRATE: jQuery.parseJSON is deprecated; use JSON.parse

Cause: The jQuery.parseJSON method in recent jQuery is identical to the native JSON.parse. As of jQuery 3.0 jQuery.parseJSON is deprecated.

Solution: Replace any use of jQuery.parseJSON with JSON.parse.

Same question as #259, does it makes sense to clear up the deprecation?

Source

@@ -289,11 +289,11 @@ var Intercooler = Intercooler || (function() {
       target = getTarget(elt);
       // Deprecated API
       if (xhr.getResponseHeader("X-IC-Trigger-Data")) {
-        var triggerArgs = $.parseJSON(xhr.getResponseHeader("X-IC-Trigger-Data"));
+        var triggerArgs = JSON.parse(xhr.getResponseHeader("X-IC-Trigger-Data"));
         triggerEvent(target, triggerValue, triggerArgs);
       } else {
         if (triggerValue.indexOf("{") >= 0) {
-          $.each($.parseJSON(triggerValue), function(event, args) {
+          $.each(JSON.parse(triggerValue), function(event, args) {
             triggerEvent(target, event, args);
           });
         } else {
@@ -304,7 +304,7 @@ var Intercooler = Intercooler || (function() {
 
     var localVars = xhr.getResponseHeader("X-IC-Set-Local-Vars");
     if (localVars) {
-      $.each($.parseJSON(localVars), function(key, val) {
+      $.each(JSON.parse(localVars), function(key, val) {
         localStorage.setItem(key, val);
       });
     }
@@ -570,7 +570,7 @@ var Intercooler = Intercooler || (function() {
 
   function processIncludes(data, str) {
     if ($.trim(str).indexOf("{") == 0) {
-      var obj = $.parseJSON(str);
+      var obj = JSON.parse(str);
       $.each(obj, function(name, value) {
         data = appendData(data, name, value);
       });
@jrun jrun changed the title Resolve jQuery.parseJSON is deprecation Resolve jQuery.parseJSON deprecation Oct 5, 2018
@Sun-Deep
Copy link

JSON.parse() is javascript standard built in standard function where parseJason() is only available if we use jQuery library.

@1cg
Copy link
Contributor

1cg commented May 12, 2020

Create a PR and I'll gladly accept it. (two years later :)

@1cg 1cg closed this as completed May 12, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants