Monday, July 27, 2009

Zend Framework, dojo and Json

I have already written about json in one, actually some of my articles. Cool functionality can be achieved using json. Thanks to http://www.json.org, http://www.zend.com and http://www.dojotoolkit.org for provide easier solutions.

I'm not gonna talk what these three are all about, but instead share a little secret about these.
Json creation in dojo is as simple as this.
var arr = new Array();
arr[0] = “apple”;
arr[1] = “ball”;
arr[2] = “cat”;

dojo.toJson(arr);


Using Zend to convert array into json took only one line of code.
Zend_Json::encode($arr);

And decoding- converting json to array, is as simple as this
Zend_Json::decode(json_string);

2 comments:

  1. I dont understand, some of your post are really good but this.. I simply dont understand

    ReplyDelete
  2. Hm, but how about encode from dojo? Have a solution?

    ReplyDelete