| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!-- Reviewed: no -->
- <!-- EN-Revision: 24249 -->
- <sect1 id="zend.json.basics">
- <title>基本的な使用法</title>
- <para>
- <classname>Zend_Json</classname> を使用するために、
- 静的な publicメソッドが 2 つ公開されています。
- 名前は <methodname>Zend_Json::encode()</methodname> および
- <methodname>Zend_Json::decode()</methodname> となります。
- </para>
- <programlisting language="php"><![CDATA[
- // 値を取得します
- $phpNative = Zend_Json::decode($encodedValue);
- // クライアントに返すために、それをエンコードします
- $json = Zend_Json::encode($phpNative);
- ]]></programlisting>
- <!-- TODO : to be translated -->
- <sect2 id="zend.json.basics.prettyprint">
- <title>Pretty-printing JSON</title>
- <para>
- Sometimes, it may be hard to explore <acronym>JSON</acronym> data generated by
- <methodname>Zend_Json::encode()</methodname>,
- since it has no spacing or indentation. In order to make it easier, <classname>Zend_Json</classname>
- allows you to pretty-print <acronym>JSON</acronym> data in the human-readable format
- with <methodname>Zend_Json::prettyPrint()</methodname>.
- </para>
- <programlisting language="php"><![CDATA[
- // クライアントに返すために、それをエンコードします
- $json = Zend_Json::encode($phpNative);
- if($debug) {
- echo Zend_Json::prettyPrint($json, array("indent" => " "));
- }
- ]]></programlisting>
- <!-- TODO : to be translated -->
- <para>
- Second optional argument of <methodname>Zend_Json::prettyPrint()</methodname> is an option array.
- Option <property>indent</property> allows to set indentation string - by default it's a single tab character.
- </para>
- </sect2>
- </sect1>
- <!--
- vim:se ts=4 sw=4 et:
- -->
|