2006-08-02 15:43:50 +00:00
|
|
|
|
<?xml version="1.0" encoding="iso-8859-1"?>
|
2008-04-23 17:44:25 +00:00
|
|
|
|
<!-- $Revision: 1.5 $ -->
|
|
|
|
|
<!-- EN-Revision: 1.4 Maintainer: kalle Status: ready -->
|
|
|
|
|
|
2007-06-20 22:25:43 +00:00
|
|
|
|
<refentry xml:id="function.json-decode" xmlns="http://docbook.org/ns/docbook">
|
2006-08-02 15:43:50 +00:00
|
|
|
|
<refnamediv>
|
|
|
|
|
<refname>json_decode</refname>
|
2008-04-23 17:44:25 +00:00
|
|
|
|
<refpurpose>Afkoder en JSON streng</refpurpose>
|
2006-08-02 15:43:50 +00:00
|
|
|
|
</refnamediv>
|
|
|
|
|
|
|
|
|
|
<refsect1 role="description">
|
|
|
|
|
&reftitle.description;
|
|
|
|
|
<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>
|
|
|
|
|
</methodsynopsis>
|
|
|
|
|
<para>
|
2008-04-23 17:44:25 +00:00
|
|
|
|
Tager en JSON enkodet streng og konverter den til en PHP variabel.
|
2006-08-02 15:43:50 +00:00
|
|
|
|
</para>
|
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
|
|
<refsect1 role="parameters">
|
|
|
|
|
&reftitle.parameters;
|
|
|
|
|
<para>
|
|
|
|
|
<variablelist>
|
|
|
|
|
<varlistentry>
|
|
|
|
|
<term><parameter>json</parameter></term>
|
|
|
|
|
<listitem>
|
|
|
|
|
<para>
|
2008-04-23 17:44:25 +00:00
|
|
|
|
JSON streng til at afkode.
|
2006-08-02 15:43:50 +00:00
|
|
|
|
</para>
|
|
|
|
|
</listitem>
|
|
|
|
|
</varlistentry>
|
|
|
|
|
<varlistentry>
|
|
|
|
|
<term><parameter>assoc</parameter></term>
|
|
|
|
|
<listitem>
|
|
|
|
|
<para>
|
2008-04-23 17:44:25 +00:00
|
|
|
|
N<>r &true;, vil returnerede objekter bliver konverteret til
|
|
|
|
|
et associative <type>array</type>s.
|
2006-08-02 15:43:50 +00:00
|
|
|
|
</para>
|
|
|
|
|
</listitem>
|
|
|
|
|
</varlistentry>
|
|
|
|
|
</variablelist>
|
|
|
|
|
</para>
|
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
|
|
<refsect1 role="returnvalues">
|
|
|
|
|
&reftitle.returnvalues;
|
|
|
|
|
<para>
|
2008-04-23 17:44:25 +00:00
|
|
|
|
Returnere et objekt eller hvis den valgfrie <parameter>assoc</parameter>
|
|
|
|
|
parameter er &true;, et assocativt <type>array</type> er returneret i stedet.
|
2006-08-02 15:43:50 +00:00
|
|
|
|
</para>
|
|
|
|
|
</refsect1>
|
|
|
|
|
|
|
|
|
|
<refsect1 role="examples">
|
|
|
|
|
&reftitle.examples;
|
|
|
|
|
<para>
|
|
|
|
|
<example>
|
2008-04-23 17:44:25 +00:00
|
|
|
|
<title><function>json_decode</function> eksempler</title>
|
2006-08-02 15:43:50 +00:00
|
|
|
|
<programlisting role="php">
|
|
|
|
|
<![CDATA[
|
|
|
|
|
<?php
|
|
|
|
|
$json = '{"a":1,"b":2,"c":3,"d":4,"e":5}';
|
|
|
|
|
|
|
|
|
|
var_dump(json_decode($json));
|
|
|
|
|
var_dump(json_decode($json, true));
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
]]>
|
|
|
|
|
</programlisting>
|
|
|
|
|
&example.outputs;
|
|
|
|
|
<screen>
|
|
|
|
|
<![CDATA[
|
|
|
|
|
object(stdClass)#1 (5) {
|
|
|
|
|
["a"] => int(1)
|
|
|
|
|
["b"] => int(2)
|
|
|
|
|
["c"] => int(3)
|
|
|
|
|
["d"] => int(4)
|
|
|
|
|
["e"] => int(5)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
array(5) {
|
|
|
|
|
["a"] => int(1)
|
|
|
|
|
["b"] => int(2)
|
|
|
|
|
["c"] => int(3)
|
|
|
|
|
["d"] => int(4)
|
|
|
|
|
["e"] => int(5)
|
|
|
|
|
}
|
|
|
|
|
]]>
|
|
|
|
|
</screen>
|
|
|
|
|
</example>
|
2008-01-23 22:05:59 +00:00
|
|
|
|
<example>
|
|
|
|
|
<programlisting role="php">
|
|
|
|
|
<![CDATA[
|
|
|
|
|
<?php
|
|
|
|
|
|
|
|
|
|
$json = '{"foo-bar": 12345}';
|
|
|
|
|
|
|
|
|
|
$obj = json_decode($json);
|
|
|
|
|
print $obj->{'foo-bar'}; // 12345
|
|
|
|
|
|
|
|
|
|
?>
|
|
|
|
|
]]>
|
|
|
|
|
</programlisting>
|
|
|
|
|
</example>
|
2006-08-02 15:43:50 +00:00
|
|
|
|
</para>
|
|
|
|
|
</refsect1>
|
|
|
|
|
|
2007-05-25 19:56:26 +00:00
|
|
|
|
<refsect1 role="notes">
|
|
|
|
|
&reftitle.notes;
|
|
|
|
|
<caution>
|
|
|
|
|
<para>
|
2008-04-23 17:44:25 +00:00
|
|
|
|
Denne funktion vil returnere &false; hvis den enkodet JSON data struktur's
|
|
|
|
|
dybde er mere en 127 elementer.
|
2007-05-25 19:56:26 +00:00
|
|
|
|
</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>
|
2008-04-23 17:44:25 +00:00
|
|
|
|
<entry>Max struktur dybde blev <20>ndret fra 20 til 128</entry>
|
2007-05-25 19:56:26 +00:00
|
|
|
|
</row>
|
|
|
|
|
</tbody>
|
|
|
|
|
</tgroup>
|
|
|
|
|
</informaltable>
|
|
|
|
|
</para>
|
|
|
|
|
</refsect1>
|
|
|
|
|
|
2006-08-02 15:43:50 +00:00
|
|
|
|
<refsect1 role="seealso">
|
|
|
|
|
&reftitle.seealso;
|
|
|
|
|
<para>
|
|
|
|
|
<simplelist>
|
|
|
|
|
<member><function>json_encode</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
|
|
|
|
|
-->
|