cvs: phpdoc-de /reference/json book.xml constants.xml reference.xml setup.xml /reference/json/functions json-decode.xml json-encode.xml
json-last-error.xml
| From: | Carola 'Sammy' Kummert | Date: | Sat, 07 Mar 2009 23:32:59 +0000 |
| Subject: | cvs: phpdoc-de /reference/json book.xml constants.xml reference.xml setup.xml /reference/json/functions json-decode.xml json-encode.xml json-last-error.xml |
||
| Groups: | php.doc.de | ||
| Request: | Send a blank email to doc-de+get-3324@lists.php.net to get a copy of this message | ||
sammywg Sat Mar 7 23:32:59 2009 UTC
Added files:
/phpdoc-de/reference/json/functions json-last-error.xml
Modified files:
/phpdoc-de/reference/json book.xml constants.xml reference.xml
setup.xml
/phpdoc-de/reference/json/functions json-decode.xml json-encode.xml
Log:
sync to en
http://cvs.php.net/viewvc.cgi/phpdoc-de/reference/json/book.xml?r1=1.3&r2=1.4&diff_format=u Index: phpdoc-de/reference/json/book.xml diff -u phpdoc-de/reference/json/book.xml:1.3 phpdoc-de/reference/json/book.xml:1.4 --- phpdoc-de/reference/json/book.xml:1.3 Fri Feb 6 11:26:40 2009 +++ phpdoc-de/reference/json/book.xml Sat Mar 7 23:32:59 2009 @@ -1,20 +1,18 @@ -<?xml version="1.0" encoding="iso-8859-1"?> -<!-- EN-Revision: 1.3 Maintainer: nobody Status: ready --> -<!-- $Revision: 1.3 $ --> -<!-- Purpose: basic.other --> -<!-- Membership: pecl, bundled --> +<?xml version="1.0" encoding="utf-8"?> +<!-- $Revision: 1.4 $ --> +<!-- EN-Revision: 1.6 Maintainer: sammywg Status: ready --> <book xml:id="book.json" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> - <title>JSON &Functions;</title> + <title>JavaScript-Objekt-Notation</title> <titleabbrev>JSON</titleabbrev> <preface xml:id="intro.json"> &reftitle.intro; <para> - Diese Erweiterung implementiert das <link - xlink:href="&url.json;">JavaScript Object Notation (JSON)</link> Format zum - Datenaustausch. Die Dekodierung wird von einem Parser übernommen, der - auf dem JSON_checker von Douglas Crockford basiert. + Diese Erweiterung implementiert das <link xlink:href="&url.json;" + >JavaScript-Objekt-Notation (JSON)</link>-Datenaustauschformat. Die + Dekodierung wird von einem Parser übernommen, der auf dem JSON_checker + von Douglas Crockford basiert. </para> </preface> @@ -23,6 +21,7 @@ &reference.json.reference; </book> + <!-- Keep this comment at the end of the file Local variables: mode: sgml http://cvs.php.net/viewvc.cgi/phpdoc-de/reference/json/constants.xml?r1=1.2&r2=1.3&diff_format=u Index: phpdoc-de/reference/json/constants.xml diff -u phpdoc-de/reference/json/constants.xml:1.2 phpdoc-de/reference/json/constants.xml:1.3 --- phpdoc-de/reference/json/constants.xml:1.2 Fri Feb 6 11:26:40 2009 +++ phpdoc-de/reference/json/constants.xml Sat Mar 7 23:32:59 2009 @@ -1,12 +1,63 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- $Revision: 1.2 $ --> -<!-- EN-Revision: 1.2 Maintainer: nobody Status: ready --> +<!-- $Revision: 1.3 $ --> +<!-- EN-Revision: 1.8 Maintainer: sammywg Status: ready --> <appendix xml:id="json.constants" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> &reftitle.constants; - &no.constants; + &extension.constants; + <para> + Die folgenden Konstanten geben den Typ des Fehlers an, der von + <function>json_last_error</function> zurückgegeben wurde. Alle Konstanten + sind seit PHP 5.3.0 verfügbar. + </para> + <variablelist> + <varlistentry> + <term> + <constant>JSON_ERROR_NONE</constant> + (<type>integer</type>) + </term> + <listitem> + <simpara> + Kein Fehler aufgetreten. + </simpara> + </listitem> + </varlistentry> + <varlistentry> + <term> + <constant>JSON_ERROR_DEPTH</constant> + (<type>integer</type>) + </term> + <listitem> + <simpara> + Die maximale Stacktiefe wurde überschritten. + </simpara> + </listitem> + </varlistentry> + <varlistentry> + <term> + <constant>JSON_ERROR_CTRL_CHAR</constant> + (<type>integer</type>) + </term> + <listitem> + <simpara> + Steuerzeichenfehler, möglicherweise unkorrekt kodiert. + </simpara> + </listitem> + </varlistentry> + <varlistentry> + <term> + <constant>JSON_ERROR_SYNTAX</constant> + (<type>integer</type>) + </term> + <listitem> + <simpara> + Syntaxfehler. + </simpara> + </listitem> + </varlistentry> + </variablelist> </appendix> - + <!-- Keep this comment at the end of the file Local variables: mode: sgml @@ -27,4 +78,3 @@ vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> - http://cvs.php.net/viewvc.cgi/phpdoc-de/reference/json/reference.xml?r1=1.6&r2=1.7&diff_format=u Index: phpdoc-de/reference/json/reference.xml diff -u phpdoc-de/reference/json/reference.xml:1.6 phpdoc-de/reference/json/reference.xml:1.7 --- phpdoc-de/reference/json/reference.xml:1.6 Fri Feb 6 11:26:40 2009 +++ phpdoc-de/reference/json/reference.xml Sat Mar 7 23:32:59 2009 @@ -1,9 +1,9 @@ -<?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.6 $ --> -<!-- EN-Revision: 1.6 Maintainer: nobody Status: ready --> +<?xml version="1.0" encoding="utf-8"?> +<!-- $Revision: 1.7 $ --> +<!-- EN-Revision: 1.8 Maintainer: sammywg Status: ready --> <reference xml:id="ref.json" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> - <title>JSON &Functions;</title> + <title>JSON-&Functions;</title> &reference.json.entities.functions; @@ -29,4 +29,3 @@ vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> - http://cvs.php.net/viewvc.cgi/phpdoc-de/reference/json/setup.xml?r1=1.4&r2=1.5&diff_format=u Index: phpdoc-de/reference/json/setup.xml diff -u phpdoc-de/reference/json/setup.xml:1.4 phpdoc-de/reference/json/setup.xml:1.5 --- phpdoc-de/reference/json/setup.xml:1.4 Fri Feb 6 11:26:40 2009 +++ phpdoc-de/reference/json/setup.xml Sat Mar 7 23:32:59 2009 @@ -1,6 +1,6 @@ -<?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.4 $ --> -<!-- EN-Revision: 1.2 Maintainer: nobody Status: ready --> +<?xml version="1.0" encoding="utf-8"?> +<!-- $Revision: 1.5 $ --> +<!-- EN-Revision: 1.4 Maintainer: sammywg Status: ready --> <chapter xml:id="json.setup" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> &reftitle.setup; @@ -8,10 +8,11 @@ <section xml:id="json.requirements"> &reftitle.required; <para> - Ab PHP 5.2.0 ist die JSON-Erweiterung standardmäßig verfügbar. + Seit PHP 5.2.0 ist die JSON-Erweiterung standardmäÃig mit PHP gebündelt + und kompiliert. </para> <para> - &pecl.info; + &pecl.info; <link xlink:href="&url.pecl.package;json">&url.pecl.package;json</link> </para> </section> @@ -32,7 +33,7 @@ </section> </chapter> - + <!-- Keep this comment at the end of the file Local variables: mode: sgml @@ -53,4 +54,3 @@ vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> - http://cvs.php.net/viewvc.cgi/phpdoc-de/reference/json/functions/json-decode.xml?r1=1.2&r2=1.3&diff_format=u Index: phpdoc-de/reference/json/functions/json-decode.xml diff -u phpdoc-de/reference/json/functions/json-decode.xml:1.2 phpdoc-de/reference/json/functions/json-decode.xml:1.3 --- phpdoc-de/reference/json/functions/json-decode.xml:1.2 Fri Feb 6 11:26:40 2009 +++ phpdoc-de/reference/json/functions/json-decode.xml Sat Mar 7 23:32:59 2009 @@ -1,10 +1,11 @@ -<?xml version="1.0" encoding="iso-8859-1"?> -<!-- EN-Revision: 1.1 Maintainer: nobody Status: ready --> -<!-- $Revision: 1.2 $ --> +<?xml version="1.0" encoding="utf-8"?> +<!-- $Revision: 1.3 $ --> +<!-- EN-Revision: 1.10 Maintainer: sammywg Status: ready --> + <refentry xml:id="function.json-decode" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>json_decode</refname> - <refpurpose>Dekodiert einen JSON-String</refpurpose> + <refpurpose>Dekodiert eine JSON-Zeichenkette</refpurpose> </refnamediv> <refsect1 role="description"> @@ -12,10 +13,11 @@ <methodsynopsis> <type>mixed</type><methodname>json_decode</methodname> <methodparam><type>string</type><parameter>json</parameter></methodparam> - <methodparam choice="opt"><type>bool</type><parameter>assoc</parameter></methodparam> + <methodparam choice="opt"><type>bool</type><parameter>assoc</parameter><initializer>false</initializer></methodparam> + <methodparam choice="opt"><type>int</type><parameter>depth</parameter><initializer>512</initializer></methodparam> </methodsynopsis> <para> - Konvertiert einen JSON kodierten String in eine entsprechende PHP-Variable. + Konvertiert eine JSON-kodierte Zeichenkette in eine PHP-Variable. </para> </refsect1> @@ -35,7 +37,16 @@ <term><parameter>assoc</parameter></term> <listitem> <para> - Wenn &true;, wird <type>object</type> in ein assoziatives <type>Array</type> konvertiert. + Wenn &true;, werden zurückgegebene <type>Objekte</type> in assoziative + <type>Array</type>s konvertiert. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>depth</parameter></term> + <listitem> + <para> + </para> </listitem> </varlistentry> @@ -47,8 +58,8 @@ &reftitle.returnvalues; <para> Gibt ein <type>Objekt</type> oder, wenn der optionale Parameter - <parameter>assoc</parameter> auf &true; gesetzt ist, ein assoziatives - <type>Array</type> zurück. + <parameter>assoc</parameter> auf &true; gesetzt ist, stattdessen ein + assoziatives <type>Array</type> zurück. </para> </refsect1> @@ -56,7 +67,7 @@ &reftitle.examples; <para> <example> - <title><function>json_decode</function> Beispiel</title> + <title><function>json_decode</function>-Beispiele</title> <programlisting role="php"> <![CDATA[ <?php @@ -89,6 +100,83 @@ ]]> </screen> </example> + <example> + <title>Ein weiteres Beispiel</title> + <programlisting role="php"> +<![CDATA[ +<?php + +$json = '{"foo-bar": 12345}'; + +$obj = json_decode($json); +print $obj->{'foo-bar'}; // 12345 + +?> +]]> + </programlisting> + </example> + <example> + <title>Häufige Fehler bei der Verwendung von <function>json_decode</function></title> + <programlisting role="php"> +<![CDATA[ +<?php + +// die folgenden Zeichenketten sind gültiges JavaSkript aber kein gültiges JSON + +// der Name und der Wert müssen in doppelten Anführungszeichen eingeschlossen werden +// einfache Anführungszeichen sind ungültig +$bad_json = "{ 'bar': 'baz' }"; +json_decode($bad_json); // null + +// der Name muss in doppelten Anführungszeichen eingeschlossen werden +$bad_json = '{ bar: "baz" }'; +json_decode($bad_json); // null + +// nachfolgende Kommata sind nicht erlaubt +$bad_json = '{ bar: "baz", }'; +json_decode($bad_json); // null + +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + + <refsect1 role="notes"> + &reftitle.notes; + <note> + <para> + Die JSON-Spezifikation ist nicht JavaSkript, aber ein Subset davon. + </para> + </note> + <caution> + <para> + Diese Funktion gibt &false; zurück, wenn JSON-kodierte Daten tiefer als + 127 Ebenen verschachtelt sind. + </para> + </caution> + </refsect1> + + <refsect1 role="changelog"> + &reftitle.changelog; + <para> + <informaltable> + <tgroup cols="2"> + <thead> + <row> + <entry>&Version;</entry> + <entry>&Description;</entry> + </row> + </thead> + <tbody> + <row> + <entry>5.2.3</entry> + <entry>Die Verschachtelungsgrenze wurde von 20 auf 128 angehoben.</entry> + </row> + </tbody> + </tgroup> + </informaltable> </para> </refsect1> @@ -100,8 +188,10 @@ </simplelist> </para> </refsect1> + </refentry> + <!-- Keep this comment at the end of the file Local variables: mode: sgml http://cvs.php.net/viewvc.cgi/phpdoc-de/reference/json/functions/json-encode.xml?r1=1.2&r2=1.3&diff_format=u Index: phpdoc-de/reference/json/functions/json-encode.xml diff -u phpdoc-de/reference/json/functions/json-encode.xml:1.2 phpdoc-de/reference/json/functions/json-encode.xml:1.3 --- phpdoc-de/reference/json/functions/json-encode.xml:1.2 Fri Feb 6 11:26:40 2009 +++ phpdoc-de/reference/json/functions/json-encode.xml Sat Mar 7 23:32:59 2009 @@ -1,10 +1,11 @@ -<?xml version="1.0" encoding="iso-8859-1"?> -<!-- EN-Revision: 1.2 Maintainer: nobody Status: ready --> -<!-- $Revision: 1.2 $ --> +<?xml version="1.0" encoding="utf-8"?> +<!-- $Revision: 1.3 $ --> +<!-- EN-Revision: 1.8 Maintainer: sammywg Status: ready --> + <refentry xml:id="function.json-encode" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>json_encode</refname> - <refpurpose>Gibt einen Wert in JSON-Darstellung zurück</refpurpose> + <refpurpose>Gibt die JSON-Repräsentation eines Wertes zurück</refpurpose> </refnamediv> <refsect1 role="description"> @@ -12,9 +13,10 @@ <methodsynopsis> <type>string</type><methodname>json_encode</methodname> <methodparam><type>mixed</type><parameter>value</parameter></methodparam> + <methodparam choice="opt"><type>int</type><parameter>options</parameter><initializer>0</initializer></methodparam> </methodsynopsis> <para> - Gibt eine Zeichenkette zurück, die die JSON-Darstellung von + Gibt eine Zeichenkette zurück, die die JSON-Darstellung von <parameter>value</parameter> beinhaltet. </para> </refsect1> @@ -27,11 +29,22 @@ <term><parameter>value</parameter></term> <listitem> <para> - Der zu kodierende <parameter>value</parameter>. Kann von jedem Typ außer + Der zu kodierende <parameter>value</parameter>. Kann von jedem Typ auÃer <type>Ressource</type> sein. </para> <para> - Diese Funktion funktioniert nur mit UTF-8 kodierten Daten. + Diese Funktion arbeitet nur mit UTF-8-kodierten Daten. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>options</parameter></term> + <listitem> + <para> + Bitmaske bestehend aus <constant>PHP_JSON_HEX_QUOT</constant>, + <constant>PHP_JSON_HEX_TAG</constant>, + <constant>PHP_JSON_HEX_AMP</constant> und + <constant>PHP_JSON_HEX_APOS</constant>. StandardmäÃig auf 0 gesetzt. </para> </listitem> </varlistentry> @@ -42,7 +55,31 @@ <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> - Gibt bei Erfolg einen JSON kodierten <type>String</type> zurück. + Gibt bei Erfolg einen JSON-kodierten <type>String</type> zurück. + </para> + </refsect1> + + <refsect1 role="changelog"> + &reftitle.changelog; + <para> + <informaltable> + <tgroup cols="2"> + <thead> + <row> + <entry>&Version;</entry> + <entry>&Description;</entry> + </row> + </thead> + <tbody> + <row> + <entry>5.2.1</entry> + <entry> + Unterstützung für JSON-kodierte Grundtypen hinzugefügt. + </entry> + </row> + </tbody> + </tgroup> + </informaltable> </para> </refsect1> @@ -50,7 +87,7 @@ &reftitle.examples; <para> <example> - <title>A <function>json_encode</function> Beispiel</title> + <title>Ein <function>json_encode</function>-Beispiel</title> <programlisting role="php"> <![CDATA[ <?php @@ -78,8 +115,10 @@ </simplelist> </para> </refsect1> + </refentry> + <!-- Keep this comment at the end of the file Local variables: mode: sgml http://cvs.php.net/viewvc.cgi/phpdoc-de/reference/json/functions/json-last-error.xml?view=markup&rev=1.1 Index: phpdoc-de/reference/json/functions/json-last-error.xml +++ phpdoc-de/reference/json/functions/json-last-error.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.4 Maintainer: sammywg Status: ready --> <refentry xml:id="function.json-last-error" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>json_last_error</refname> <refpurpose>Gibt den letzten aufgetretenen Fehler zurück</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>int</type><methodname>json_last_error</methodname> <void /> </methodsynopsis> <para> Gibt (sofern vorhanden) den letzten Fehler zurück, der beim letzten Parsen von JSON aufgetreten ist. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; &no.function.parameters; </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Gibt einen Integer zurück, der Wert kann eine der folgenden Konstanten sein: </para> <table> <title>JSON-Fehlercodes</title> <tgroup cols="2"> <thead> <row> <entry>Konstante</entry> <entry>Bedeutung</entry> </row> </thead> <tbody> <row> <entry><constant>JSON_ERROR_NONE</constant></entry> <entry>Kein Fehler aufgetreten.</entry> </row> <row> <entry><constant>JSON_ERROR_DEPTH</constant></entry> <entry>Die maximale Stacktiefe wurde überschritten.</entry> </row> <row> <entry><constant>JSON_ERROR_CTRL_CHAR</constant></entry> <entry>Steuerzeichenfehler, möglicherweise unkorrekt kodiert.</entry> </row> <row> <entry><constant>JSON_ERROR_SYNTAX</constant></entry> <entry>Syntaxfehler.</entry> </row> </tbody> </tgroup> </table> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title><function>json_last_error</function>-Beispiel</title> <programlisting role="php"> <![CDATA[ <?php // Ein gültiger JSON-String $json[] = '{"Organisation": "PHP-Dokumentationsteam"}'; // Ein ungültiger JSON-String, der einen Syntaxfehler hervorruft, // in diesem Fall werden ' anstelle von " als Anführungszeichen verwendet $json[] = "{'Organisation': 'PHP-Dokumentationsteam'}"; foreach($json as $string) { echo 'Dekodiere: ' . $string; json_decode($string); switch(json_last_error()) { case JSON_ERROR_DEPTH: echo ' - Maximale Stacktiefe überschritten'; break; case JSON_ERROR_CTRL_CHAR: echo ' - Unerwartetes Steuerzeichen gefunden'; break; case JSON_ERROR_SYNTAX: echo ' - Syntaxfehler, ungültiges JSON'; break; case JSON_ERROR_NONE: echo ' - Keine Fehler'; break; } echo PHP_EOL; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ Decoding: {"Organisation": "PHP-Dokumentationsteam"} - Keine Fehler Decoding: {'Organisation': 'PHP-Dokumentationsteam'} - Syntaxfehler, ungültiges JSON ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>json_decode</function></member> </simplelist> </para> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->
http://cvs.php.net/viewvc.cgi/phpdoc-de/reference/json/book.xml?r1=1.3&r2=1.4&diff_format=u Index: phpdoc-de/reference/json/book.xml diff -u phpdoc-de/reference/json/book.xml:1.3 phpdoc-de/reference/json/book.xml:1.4 --- phpdoc-de/reference/json/book.xml:1.3 Fri Feb 6 11:26:40 2009 +++ phpdoc-de/reference/json/book.xml Sat Mar 7 23:32:59 2009 @@ -1,20 +1,18 @@ -<?xml version="1.0" encoding="iso-8859-1"?> -<!-- EN-Revision: 1.3 Maintainer: nobody Status: ready --> -<!-- $Revision: 1.3 $ --> -<!-- Purpose: basic.other --> -<!-- Membership: pecl, bundled --> +<?xml version="1.0" encoding="utf-8"?> +<!-- $Revision: 1.4 $ --> +<!-- EN-Revision: 1.6 Maintainer: sammywg Status: ready --> <book xml:id="book.json" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> - <title>JSON &Functions;</title> + <title>JavaScript-Objekt-Notation</title> <titleabbrev>JSON</titleabbrev> <preface xml:id="intro.json"> &reftitle.intro; <para> - Diese Erweiterung implementiert das <link - xlink:href="&url.json;">JavaScript Object Notation (JSON)</link> Format zum - Datenaustausch. Die Dekodierung wird von einem Parser übernommen, der - auf dem JSON_checker von Douglas Crockford basiert. + Diese Erweiterung implementiert das <link xlink:href="&url.json;" + >JavaScript-Objekt-Notation (JSON)</link>-Datenaustauschformat. Die + Dekodierung wird von einem Parser übernommen, der auf dem JSON_checker + von Douglas Crockford basiert. </para> </preface> @@ -23,6 +21,7 @@ &reference.json.reference; </book> + <!-- Keep this comment at the end of the file Local variables: mode: sgml http://cvs.php.net/viewvc.cgi/phpdoc-de/reference/json/constants.xml?r1=1.2&r2=1.3&diff_format=u Index: phpdoc-de/reference/json/constants.xml diff -u phpdoc-de/reference/json/constants.xml:1.2 phpdoc-de/reference/json/constants.xml:1.3 --- phpdoc-de/reference/json/constants.xml:1.2 Fri Feb 6 11:26:40 2009 +++ phpdoc-de/reference/json/constants.xml Sat Mar 7 23:32:59 2009 @@ -1,12 +1,63 @@ <?xml version="1.0" encoding="utf-8"?> -<!-- $Revision: 1.2 $ --> -<!-- EN-Revision: 1.2 Maintainer: nobody Status: ready --> +<!-- $Revision: 1.3 $ --> +<!-- EN-Revision: 1.8 Maintainer: sammywg Status: ready --> <appendix xml:id="json.constants" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> &reftitle.constants; - &no.constants; + &extension.constants; + <para> + Die folgenden Konstanten geben den Typ des Fehlers an, der von + <function>json_last_error</function> zurückgegeben wurde. Alle Konstanten + sind seit PHP 5.3.0 verfügbar. + </para> + <variablelist> + <varlistentry> + <term> + <constant>JSON_ERROR_NONE</constant> + (<type>integer</type>) + </term> + <listitem> + <simpara> + Kein Fehler aufgetreten. + </simpara> + </listitem> + </varlistentry> + <varlistentry> + <term> + <constant>JSON_ERROR_DEPTH</constant> + (<type>integer</type>) + </term> + <listitem> + <simpara> + Die maximale Stacktiefe wurde überschritten. + </simpara> + </listitem> + </varlistentry> + <varlistentry> + <term> + <constant>JSON_ERROR_CTRL_CHAR</constant> + (<type>integer</type>) + </term> + <listitem> + <simpara> + Steuerzeichenfehler, möglicherweise unkorrekt kodiert. + </simpara> + </listitem> + </varlistentry> + <varlistentry> + <term> + <constant>JSON_ERROR_SYNTAX</constant> + (<type>integer</type>) + </term> + <listitem> + <simpara> + Syntaxfehler. + </simpara> + </listitem> + </varlistentry> + </variablelist> </appendix> - + <!-- Keep this comment at the end of the file Local variables: mode: sgml @@ -27,4 +78,3 @@ vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> - http://cvs.php.net/viewvc.cgi/phpdoc-de/reference/json/reference.xml?r1=1.6&r2=1.7&diff_format=u Index: phpdoc-de/reference/json/reference.xml diff -u phpdoc-de/reference/json/reference.xml:1.6 phpdoc-de/reference/json/reference.xml:1.7 --- phpdoc-de/reference/json/reference.xml:1.6 Fri Feb 6 11:26:40 2009 +++ phpdoc-de/reference/json/reference.xml Sat Mar 7 23:32:59 2009 @@ -1,9 +1,9 @@ -<?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.6 $ --> -<!-- EN-Revision: 1.6 Maintainer: nobody Status: ready --> +<?xml version="1.0" encoding="utf-8"?> +<!-- $Revision: 1.7 $ --> +<!-- EN-Revision: 1.8 Maintainer: sammywg Status: ready --> <reference xml:id="ref.json" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> - <title>JSON &Functions;</title> + <title>JSON-&Functions;</title> &reference.json.entities.functions; @@ -29,4 +29,3 @@ vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> - http://cvs.php.net/viewvc.cgi/phpdoc-de/reference/json/setup.xml?r1=1.4&r2=1.5&diff_format=u Index: phpdoc-de/reference/json/setup.xml diff -u phpdoc-de/reference/json/setup.xml:1.4 phpdoc-de/reference/json/setup.xml:1.5 --- phpdoc-de/reference/json/setup.xml:1.4 Fri Feb 6 11:26:40 2009 +++ phpdoc-de/reference/json/setup.xml Sat Mar 7 23:32:59 2009 @@ -1,6 +1,6 @@ -<?xml version="1.0" encoding="iso-8859-1"?> -<!-- $Revision: 1.4 $ --> -<!-- EN-Revision: 1.2 Maintainer: nobody Status: ready --> +<?xml version="1.0" encoding="utf-8"?> +<!-- $Revision: 1.5 $ --> +<!-- EN-Revision: 1.4 Maintainer: sammywg Status: ready --> <chapter xml:id="json.setup" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink"> &reftitle.setup; @@ -8,10 +8,11 @@ <section xml:id="json.requirements"> &reftitle.required; <para> - Ab PHP 5.2.0 ist die JSON-Erweiterung standardmäßig verfügbar. + Seit PHP 5.2.0 ist die JSON-Erweiterung standardmäÃig mit PHP gebündelt + und kompiliert. </para> <para> - &pecl.info; + &pecl.info; <link xlink:href="&url.pecl.package;json">&url.pecl.package;json</link> </para> </section> @@ -32,7 +33,7 @@ </section> </chapter> - + <!-- Keep this comment at the end of the file Local variables: mode: sgml @@ -53,4 +54,3 @@ vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> - http://cvs.php.net/viewvc.cgi/phpdoc-de/reference/json/functions/json-decode.xml?r1=1.2&r2=1.3&diff_format=u Index: phpdoc-de/reference/json/functions/json-decode.xml diff -u phpdoc-de/reference/json/functions/json-decode.xml:1.2 phpdoc-de/reference/json/functions/json-decode.xml:1.3 --- phpdoc-de/reference/json/functions/json-decode.xml:1.2 Fri Feb 6 11:26:40 2009 +++ phpdoc-de/reference/json/functions/json-decode.xml Sat Mar 7 23:32:59 2009 @@ -1,10 +1,11 @@ -<?xml version="1.0" encoding="iso-8859-1"?> -<!-- EN-Revision: 1.1 Maintainer: nobody Status: ready --> -<!-- $Revision: 1.2 $ --> +<?xml version="1.0" encoding="utf-8"?> +<!-- $Revision: 1.3 $ --> +<!-- EN-Revision: 1.10 Maintainer: sammywg Status: ready --> + <refentry xml:id="function.json-decode" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>json_decode</refname> - <refpurpose>Dekodiert einen JSON-String</refpurpose> + <refpurpose>Dekodiert eine JSON-Zeichenkette</refpurpose> </refnamediv> <refsect1 role="description"> @@ -12,10 +13,11 @@ <methodsynopsis> <type>mixed</type><methodname>json_decode</methodname> <methodparam><type>string</type><parameter>json</parameter></methodparam> - <methodparam choice="opt"><type>bool</type><parameter>assoc</parameter></methodparam> + <methodparam choice="opt"><type>bool</type><parameter>assoc</parameter><initializer>false</initializer></methodparam> + <methodparam choice="opt"><type>int</type><parameter>depth</parameter><initializer>512</initializer></methodparam> </methodsynopsis> <para> - Konvertiert einen JSON kodierten String in eine entsprechende PHP-Variable. + Konvertiert eine JSON-kodierte Zeichenkette in eine PHP-Variable. </para> </refsect1> @@ -35,7 +37,16 @@ <term><parameter>assoc</parameter></term> <listitem> <para> - Wenn &true;, wird <type>object</type> in ein assoziatives <type>Array</type> konvertiert. + Wenn &true;, werden zurückgegebene <type>Objekte</type> in assoziative + <type>Array</type>s konvertiert. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>depth</parameter></term> + <listitem> + <para> + </para> </listitem> </varlistentry> @@ -47,8 +58,8 @@ &reftitle.returnvalues; <para> Gibt ein <type>Objekt</type> oder, wenn der optionale Parameter - <parameter>assoc</parameter> auf &true; gesetzt ist, ein assoziatives - <type>Array</type> zurück. + <parameter>assoc</parameter> auf &true; gesetzt ist, stattdessen ein + assoziatives <type>Array</type> zurück. </para> </refsect1> @@ -56,7 +67,7 @@ &reftitle.examples; <para> <example> - <title><function>json_decode</function> Beispiel</title> + <title><function>json_decode</function>-Beispiele</title> <programlisting role="php"> <![CDATA[ <?php @@ -89,6 +100,83 @@ ]]> </screen> </example> + <example> + <title>Ein weiteres Beispiel</title> + <programlisting role="php"> +<![CDATA[ +<?php + +$json = '{"foo-bar": 12345}'; + +$obj = json_decode($json); +print $obj->{'foo-bar'}; // 12345 + +?> +]]> + </programlisting> + </example> + <example> + <title>Häufige Fehler bei der Verwendung von <function>json_decode</function></title> + <programlisting role="php"> +<![CDATA[ +<?php + +// die folgenden Zeichenketten sind gültiges JavaSkript aber kein gültiges JSON + +// der Name und der Wert müssen in doppelten Anführungszeichen eingeschlossen werden +// einfache Anführungszeichen sind ungültig +$bad_json = "{ 'bar': 'baz' }"; +json_decode($bad_json); // null + +// der Name muss in doppelten Anführungszeichen eingeschlossen werden +$bad_json = '{ bar: "baz" }'; +json_decode($bad_json); // null + +// nachfolgende Kommata sind nicht erlaubt +$bad_json = '{ bar: "baz", }'; +json_decode($bad_json); // null + +?> +]]> + </programlisting> + </example> + </para> + </refsect1> + + <refsect1 role="notes"> + &reftitle.notes; + <note> + <para> + Die JSON-Spezifikation ist nicht JavaSkript, aber ein Subset davon. + </para> + </note> + <caution> + <para> + Diese Funktion gibt &false; zurück, wenn JSON-kodierte Daten tiefer als + 127 Ebenen verschachtelt sind. + </para> + </caution> + </refsect1> + + <refsect1 role="changelog"> + &reftitle.changelog; + <para> + <informaltable> + <tgroup cols="2"> + <thead> + <row> + <entry>&Version;</entry> + <entry>&Description;</entry> + </row> + </thead> + <tbody> + <row> + <entry>5.2.3</entry> + <entry>Die Verschachtelungsgrenze wurde von 20 auf 128 angehoben.</entry> + </row> + </tbody> + </tgroup> + </informaltable> </para> </refsect1> @@ -100,8 +188,10 @@ </simplelist> </para> </refsect1> + </refentry> + <!-- Keep this comment at the end of the file Local variables: mode: sgml http://cvs.php.net/viewvc.cgi/phpdoc-de/reference/json/functions/json-encode.xml?r1=1.2&r2=1.3&diff_format=u Index: phpdoc-de/reference/json/functions/json-encode.xml diff -u phpdoc-de/reference/json/functions/json-encode.xml:1.2 phpdoc-de/reference/json/functions/json-encode.xml:1.3 --- phpdoc-de/reference/json/functions/json-encode.xml:1.2 Fri Feb 6 11:26:40 2009 +++ phpdoc-de/reference/json/functions/json-encode.xml Sat Mar 7 23:32:59 2009 @@ -1,10 +1,11 @@ -<?xml version="1.0" encoding="iso-8859-1"?> -<!-- EN-Revision: 1.2 Maintainer: nobody Status: ready --> -<!-- $Revision: 1.2 $ --> +<?xml version="1.0" encoding="utf-8"?> +<!-- $Revision: 1.3 $ --> +<!-- EN-Revision: 1.8 Maintainer: sammywg Status: ready --> + <refentry xml:id="function.json-encode" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>json_encode</refname> - <refpurpose>Gibt einen Wert in JSON-Darstellung zurück</refpurpose> + <refpurpose>Gibt die JSON-Repräsentation eines Wertes zurück</refpurpose> </refnamediv> <refsect1 role="description"> @@ -12,9 +13,10 @@ <methodsynopsis> <type>string</type><methodname>json_encode</methodname> <methodparam><type>mixed</type><parameter>value</parameter></methodparam> + <methodparam choice="opt"><type>int</type><parameter>options</parameter><initializer>0</initializer></methodparam> </methodsynopsis> <para> - Gibt eine Zeichenkette zurück, die die JSON-Darstellung von + Gibt eine Zeichenkette zurück, die die JSON-Darstellung von <parameter>value</parameter> beinhaltet. </para> </refsect1> @@ -27,11 +29,22 @@ <term><parameter>value</parameter></term> <listitem> <para> - Der zu kodierende <parameter>value</parameter>. Kann von jedem Typ außer + Der zu kodierende <parameter>value</parameter>. Kann von jedem Typ auÃer <type>Ressource</type> sein. </para> <para> - Diese Funktion funktioniert nur mit UTF-8 kodierten Daten. + Diese Funktion arbeitet nur mit UTF-8-kodierten Daten. + </para> + </listitem> + </varlistentry> + <varlistentry> + <term><parameter>options</parameter></term> + <listitem> + <para> + Bitmaske bestehend aus <constant>PHP_JSON_HEX_QUOT</constant>, + <constant>PHP_JSON_HEX_TAG</constant>, + <constant>PHP_JSON_HEX_AMP</constant> und + <constant>PHP_JSON_HEX_APOS</constant>. StandardmäÃig auf 0 gesetzt. </para> </listitem> </varlistentry> @@ -42,7 +55,31 @@ <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> - Gibt bei Erfolg einen JSON kodierten <type>String</type> zurück. + Gibt bei Erfolg einen JSON-kodierten <type>String</type> zurück. + </para> + </refsect1> + + <refsect1 role="changelog"> + &reftitle.changelog; + <para> + <informaltable> + <tgroup cols="2"> + <thead> + <row> + <entry>&Version;</entry> + <entry>&Description;</entry> + </row> + </thead> + <tbody> + <row> + <entry>5.2.1</entry> + <entry> + Unterstützung für JSON-kodierte Grundtypen hinzugefügt. + </entry> + </row> + </tbody> + </tgroup> + </informaltable> </para> </refsect1> @@ -50,7 +87,7 @@ &reftitle.examples; <para> <example> - <title>A <function>json_encode</function> Beispiel</title> + <title>Ein <function>json_encode</function>-Beispiel</title> <programlisting role="php"> <![CDATA[ <?php @@ -78,8 +115,10 @@ </simplelist> </para> </refsect1> + </refentry> + <!-- Keep this comment at the end of the file Local variables: mode: sgml http://cvs.php.net/viewvc.cgi/phpdoc-de/reference/json/functions/json-last-error.xml?view=markup&rev=1.1 Index: phpdoc-de/reference/json/functions/json-last-error.xml +++ phpdoc-de/reference/json/functions/json-last-error.xml <?xml version="1.0" encoding="utf-8"?> <!-- $Revision: 1.1 $ --> <!-- EN-Revision: 1.4 Maintainer: sammywg Status: ready --> <refentry xml:id="function.json-last-error" xmlns="http://docbook.org/ns/docbook"> <refnamediv> <refname>json_last_error</refname> <refpurpose>Gibt den letzten aufgetretenen Fehler zurück</refpurpose> </refnamediv> <refsect1 role="description"> &reftitle.description; <methodsynopsis> <type>int</type><methodname>json_last_error</methodname> <void /> </methodsynopsis> <para> Gibt (sofern vorhanden) den letzten Fehler zurück, der beim letzten Parsen von JSON aufgetreten ist. </para> </refsect1> <refsect1 role="parameters"> &reftitle.parameters; &no.function.parameters; </refsect1> <refsect1 role="returnvalues"> &reftitle.returnvalues; <para> Gibt einen Integer zurück, der Wert kann eine der folgenden Konstanten sein: </para> <table> <title>JSON-Fehlercodes</title> <tgroup cols="2"> <thead> <row> <entry>Konstante</entry> <entry>Bedeutung</entry> </row> </thead> <tbody> <row> <entry><constant>JSON_ERROR_NONE</constant></entry> <entry>Kein Fehler aufgetreten.</entry> </row> <row> <entry><constant>JSON_ERROR_DEPTH</constant></entry> <entry>Die maximale Stacktiefe wurde überschritten.</entry> </row> <row> <entry><constant>JSON_ERROR_CTRL_CHAR</constant></entry> <entry>Steuerzeichenfehler, möglicherweise unkorrekt kodiert.</entry> </row> <row> <entry><constant>JSON_ERROR_SYNTAX</constant></entry> <entry>Syntaxfehler.</entry> </row> </tbody> </tgroup> </table> </refsect1> <refsect1 role="examples"> &reftitle.examples; <para> <example> <title><function>json_last_error</function>-Beispiel</title> <programlisting role="php"> <![CDATA[ <?php // Ein gültiger JSON-String $json[] = '{"Organisation": "PHP-Dokumentationsteam"}'; // Ein ungültiger JSON-String, der einen Syntaxfehler hervorruft, // in diesem Fall werden ' anstelle von " als Anführungszeichen verwendet $json[] = "{'Organisation': 'PHP-Dokumentationsteam'}"; foreach($json as $string) { echo 'Dekodiere: ' . $string; json_decode($string); switch(json_last_error()) { case JSON_ERROR_DEPTH: echo ' - Maximale Stacktiefe überschritten'; break; case JSON_ERROR_CTRL_CHAR: echo ' - Unerwartetes Steuerzeichen gefunden'; break; case JSON_ERROR_SYNTAX: echo ' - Syntaxfehler, ungültiges JSON'; break; case JSON_ERROR_NONE: echo ' - Keine Fehler'; break; } echo PHP_EOL; } ?> ]]> </programlisting> &example.outputs; <screen> <![CDATA[ Decoding: {"Organisation": "PHP-Dokumentationsteam"} - Keine Fehler Decoding: {'Organisation': 'PHP-Dokumentationsteam'} - Syntaxfehler, ungültiges JSON ]]> </screen> </example> </para> </refsect1> <refsect1 role="seealso"> &reftitle.seealso; <para> <simplelist> <member><function>json_decode</function></member> </simplelist> </para> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t indent-tabs-mode:nil sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->