Why Correcting to better parse numbers Can be used. It will return a number on success and If you keep an eye on the source of the jQuery method, then it will become very fast. So if your case moves Library on display: $ ParseJSON ("1") returns
1 . I hope this will throw an error because it does not look like a valid JSON of the form:
{"firstname": "John"}
1 correctly? Is there anyway to throw an error instead?
parsing a number
NaN (not a number) otherwise
var a = parseInt ('23 '); IsNan (a); // wrong var b = parseInt ('ab'); IsNan (b); // True
Why this gives in jQuery 1
2. is executed, it will only return
1 , even if it is not a real JSON. Update . Therefore, regardless of implementation, you always get the same result.
Parsegas: function (data) {if (! Data = data type =! = "String") {return tap; } // Be sure that the leading / backward white location has been removed (IE can not handle it) data = jQuery.trim (data); // First try to parse the original JSON parser if (window.JSON & window.JSON.parse) {return window.JSON.parse (data); } // Make sure that incoming data is the logic taken from real JSON / http://json.org/json2.js (rvalidchars.test (data location (rvalidescape, "@"). Replace (rvalidtokens, " ] "Return" (Returns the JSON data only) JQuery.error ("invalid JSON:" + data); return (rvalidbraces, "")) {return (new function ("return" + data)) },
No comments:
Post a Comment