Skip to content

Commit d87d7ec

Browse files
committed
parseJSON: Warn and return null on null input. Close gh-45.
1 parent 3d6cc15 commit d87d7ec

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ jQuery.fn.init.prototype = jQuery.fn;
4040

4141
// Let $.parseJSON(falsy_value) return null
4242
jQuery.parseJSON = function( json ) {
43-
if ( !json && json !== null ) {
43+
if ( !json ) {
4444
migrateWarn("jQuery.parseJSON requires a valid JSON string");
4545
return null;
4646
}

test/core.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ test( "jQuery.parseJSON() falsy values", function() {
107107
expectNoWarning( "valid JSON", function() {
108108
jQuery.parseJSON("{\"a\":1}");
109109
});
110-
expectNoWarning( "actual null", function() {
110+
expectWarning( "actual null", function() {
111111
jQuery.parseJSON(null);
112112
});
113113
expectNoWarning( "string null", function() {

0 commit comments

Comments
 (0)