JayminKapish
Subscribe to jayminkapish RSS Friend Jaymin Patel on Facebook Follow Jaymin Patel on Twitter

« Go to home page

JSON and WordPress

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")


9 Responses


Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>


About

Wordpress Work

Plugins I like

Recent Posts

Wordpress News

Blogroll

Connect

I am excited about