If you are using wordpress 2.9+ , It is just so easy. You don’t have to worry about the evil thing called “eval” and you don’t have to worry about including JSON javascript parser with your theme/plugin.
WordPress 2.9+ contains the json2.js from json.org.
So, just put a line in your plugin
wp_enqueue_script("json2");//must be put inside some function called at wp_print_script
Or here is the complete code, how to enqueue the script.
add_action("wp_print_scripts","load_my_script"); function load_my_script(){ //en queue JSON2.js wp_enqueue_script("json2"); }
and boy! wordpress will load the JSON parser, Now you are ready to use the JSON parser.
Here is more details about what you can do with the JSON parser