Reputation: 3541
I'm facing issue when parsing a json data. Below is the function which throws error
parseJSON: function( data ) {
//Attempt to parse using the native JSON parser first
if (window.JSON && window.JSON.parse) {
return window.JSON.parse( data ); //We are getting error from this line due to data is undefined
}
if (data === null) {
return data;
}
if ( typeof data === "string" ) {
data = jQuery.trim( data );
if ( data ) {
if ( rvalidchars.test( data.replace( rvalidescape, "@" )
.replace( rvalidtokens, "]" )
.replace( rvalidbraces, "")) ) {
return ( new Function( "return " + data ) )();
}
}
}
jQuery.error( "Invalid JSON: " + data );
}
Thanks in Advance
Upvotes: 1
Views: 574
Reputation: 2117
Your JSON data might be wrong. See
http://jsonformatter.curiousconcept.com/
to validate it.
Upvotes: 2