導入

基本的な使用法

Zend_Json を使用するために、 静的な publicメソッドが 2 つ公開されています。 名前は Zend_Json::encode() および Zend_Json::decode() となります。

  1. // 値を取得します
  2. // クライアントに返すために、それをエンコードします

Pretty-printing JSON

Sometimes, it may be hard to explore JSON data generated by Zend_Json::encode(), since it has no spacing or indentation. In order to make it easier, Zend_Json allows you to pretty-print JSON data in the human-readable format with Zend_Json::prettyPrint().

  1. // クライアントに返すために、それをエンコードします
  2. "indent" => " "));
  3. }

Second optional argument of Zend_Json::prettyPrint() is an option array. Option indent allows to set indentation string - by default it's a single tab character.


導入