Now parse Client side json with Wordpress

Jotted by brajesh on January 21, 2010

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

http://www.json.org/js.html

[blinklist] [Bloglines] [del.icio.us] [Digg] [dzone] [Facebook] [Ma.gnolia] [Mister Wong] [Reddit] [Sphere] [Sphinn] [StumbleUpon] [Technorati] [Email]



Get Adobe Flash playerPlugin by wpburn.com wordpress themes