Apparently jQuery has the ability to decode a given object or string into a JSON object. However, I have a JS object that I need to POST back to the server and I find no utility in jQuery that wraps the JSON.stringify() function. That function is found in Chrome, Safari 4, FF3.6, and IE8 but is not found in earlier browsers. I can use it natively in the browsers that support it, but otherwise am forced to fall back to using Crockford's JSON scripts.
Is there some built-in with jQuery that handles JSON encoding and decoding that takes the place of the Crockford scripts?
You might want to check this out: http://www.json.org/js.html
You can use "Closure Library" (Google) to make a cross browser JSON encoder/decoder.
Just go to http://closure-compiler.appspot.com/
and insert the following into the text field, then hit "Compile":
// ==ClosureCompiler== // @compilation_level ADVANCED_OPTIMIZATIONS // @output_file_name default.js // @use_closure_library true // ==/ClosureCompiler== goog.require('goog.json'); if (!window['JSON']) window['JSON']={}; if (typeof window['JSON']['stringify'] !== 'function') window['JSON']['stringify']=goog.json.serialize; if (typeof window['JSON']['parse'] !== 'function') window['JSON']['parse']=goog.json.parse;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With