reference/json/functions/json-encode.xml
9f2e30a00afda6d6b6a3e19b13956150c2eaf2c1
9f2e30a00afda6d6b6a3e19b13956150c2eaf2c1
...
...
@@ -11,15 +11,21 @@
11
11
<methodsynopsis>
12
12
<type class="union"><type>string</type><type>false</type></type><methodname>json_encode</methodname>
13
13
<methodparam><type>mixed</type><parameter>value</parameter></methodparam>
14
-
<methodparam choice="opt"><type>int</type><parameter>options</parameter><initializer>0</initializer></methodparam>
14
+
<methodparam choice="opt"><type>int</type><parameter>flags</parameter><initializer>0</initializer></methodparam>
15
15
<methodparam choice="opt"><type>int</type><parameter>depth</parameter><initializer>512</initializer></methodparam>
16
16
</methodsynopsis>
17
17
<para>
18
18
Returns a string containing the JSON representation of the supplied
19
-
<parameter>value</parameter>.
19
+
<parameter>value</parameter>. If the parameter is an &array; or &object;,
20
+
it will be serialized recursively.
20
21
</para>
21
22
<para>
22
-
The encoding is affected by the supplied <parameter>options</parameter>
23
+
If a value to be serialized is an object, then by default only publicly visible
24
+
properties will be included. Alternatively, a class may implement <interfacename>JsonSerializable</interfacename>
25
+
to control how its values are serialized to <acronym>JSON</acronym>.
26
+
</para>
27
+
<para>
28
+
The encoding is affected by the supplied <parameter>flags</parameter>
23
29
and additionally the encoding of float values depends on the value of
24
30
<link linkend="ini.serialize-precision">serialize_precision</link>.
25
31
</para>
...
...
@@ -43,7 +49,7 @@
43
49
</listitem>
44
50
</varlistentry>
45
51
<varlistentry>
46
-
<term><parameter>options</parameter></term>
52
+
<term><parameter>flags</parameter></term>
47
53
<listitem>
48
54
<para>
49
55
Bitmask consisting of
...
...
@@ -102,7 +108,7 @@
102
108
<entry>7.3.0</entry>
103
109
<entry>
104
110
<constant>JSON_THROW_ON_ERROR</constant>
105
-
<parameter>options</parameter> was added.
111
+
<parameter>flags</parameter> was added.
106
112
</entry>
107
113
</row>
108
114
<row>
...
...
@@ -110,14 +116,14 @@
110
116
<entry>
111
117
<constant>JSON_INVALID_UTF8_IGNORE</constant>, and
112
118
<constant>JSON_INVALID_UTF8_SUBSTITUTE</constant>
113
-
<parameter>options</parameter> were added.
119
+
<parameter>flags</parameter> were added.
114
120
</entry>
115
121
</row>
116
122
<row>
117
123
<entry>7.1.0</entry>
118
124
<entry>
119
125
<constant>JSON_UNESCAPED_LINE_TERMINATORS</constant>
120
-
<parameter>options</parameter> was added.
126
+
<parameter>flags</parameter> was added.
121
127
</entry>
122
128
</row>
123
129
<row>
...
...
@@ -125,7 +131,7 @@
125
131
<entry>
126
132
<link linkend="ini.serialize-precision">serialize_precision</link> is
127
133
used instead of <link linkend="ini.precision">precision</link> when
128
-
encoding double values.
134
+
encoding <type>float</type> values.
129
135
</entry>
130
136
</row>
131
137
</tbody>
...
...
@@ -158,7 +164,7 @@ echo json_encode($arr);
158
164
159
165
<example>
160
166
<title>
161
-
A <function>json_encode</function> example showing some options in use
167
+
A <function>json_encode</function> example showing some flags in use
162
168
</title>
163
169
<programlisting role="php">
164
170
<![CDATA[
...
...
@@ -387,12 +393,12 @@ string(2) "12"
387
393
<member><interfacename>JsonSerializable</interfacename></member>
388
394
<member><function>json_decode</function></member>
389
395
<member><function>json_last_error</function></member>
396
+
<member><function>json_last_error_msg</function></member>
390
397
<member><function>serialize</function></member>
391
398
</simplelist>
392
399
</para>
393
400
</refsect1>
394
401
</refentry>
395
-
396
402
<!-- Keep this comment at the end of the file
397
403
Local variables:
398
404
mode: sgml
399
405