If you want to encode/decode JSON within/using wordpress, you can take a look at
/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php
This file has Moxiecode_JSON class which can do that for you.
Sample code
require_once(ABSPATH."/wp-includes/js/tinymce/plugins/spellchecker/classes/utils/JSON.php");
$json_obj = new Moxiecode_JSON();
/* encode */
$json = $json_obj->encode(array("key1"=>"value1","key2"=>"value2"));
//$json should have {"key1":"value1","key2":"value2"}
/* decode */
$json_array = $json_obj->decode($json);
//$json_array will be an array("key1"=>"value1","key2"=>"value2")
[...] more details and examples on KAPISH. Share [...]
Thanks for the useful info. It’s so interesting
This blog makes me want to start my own blog.
Perfect – after struggling through the various json libraries looking for one that would likely be compatible with the majority of wordpress installs (for a plugin), I happened on this – exactly what I was looking for. Thanks!
WordPress is the best blogging platform ever. It is much better than Typepad and blogspot.”–
i host 5 of my blogs on Blogspot and it is really good for beginners. but if you want something with more features, nothing beats wordpress~*,
Maybe you could edit the webpage title JSON and WordPress – By Jaymin Patel, WordPress Developer, New York to something more catching for your content you create. I enjoyed the the writing even sononetheless.
I am using WordPress 3.0.1 and want to incorporate a json feed from another site. I’ve never used json before – how do I incorporate it into my web page so that the feed is decoded and displayed correctly? I see that WordPress has a version called json2.js in the wp-includes directory.
Thanks.
Hi Shawn, you should take a look at json_encode and json_decode function built in PHP itself.