Zend_Json-Basics.xml 1.9 KB

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