reference/json/constants.xml
3b67c8e90cdaa14f9d1a82756dcf0000ffa8f160
...
...
@@ -1,90 +1,84 @@
1
1
<?xml version="1.0" encoding="utf-8"?>
2
2
<!-- $Revision$ -->
3
-

4
3
<appendix xml:id="json.constants" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
5
4
&reftitle.constants;
6
5
&extension.constants;
7
6
<para>
8
7
The following constants indicate the type of error returned by
9
-
<function>json_last_error</function>.
8
+
<function>json_last_error</function> or stored as the <varname>code</varname>
9
+
of a <classname>JsonException</classname>.
10
10
</para>
11
11
<variablelist>
12
12
<varlistentry xml:id="constant.json-error-none">
13
13
<term>
14
14
<constant>JSON_ERROR_NONE</constant>
15
-
(<type>integer</type>)
15
+
(<type>int</type>)
16
16
</term>
17
17
<listitem>
18
18
<simpara>
19
19
No error has occurred.
20
-
Available since PHP 5.3.0.
21
20
</simpara>
22
21
</listitem>
23
22
</varlistentry>
24
23
<varlistentry xml:id="constant.json-error-depth">
25
24
<term>
26
25
<constant>JSON_ERROR_DEPTH</constant>
27
-
(<type>integer</type>)
26
+
(<type>int</type>)
28
27
</term>
29
28
<listitem>
30
29
<simpara>
31
30
The maximum stack depth has been exceeded.
32
-
Available since PHP 5.3.0.
33
31
</simpara>
34
32
</listitem>
35
33
</varlistentry>
36
34
<varlistentry xml:id="constant.json-error-state-mismatch">
37
35
<term>
38
36
<constant>JSON_ERROR_STATE_MISMATCH</constant>
39
-
(<type>integer</type>)
37
+
(<type>int</type>)
40
38
</term>
41
39
<listitem>
42
40
<simpara>
43
41
Occurs with underflow or with the modes mismatch.
44
-
Available since PHP 5.3.0.
45
42
</simpara>
46
43
</listitem>
47
44
</varlistentry>
48
45
<varlistentry xml:id="constant.json-error-ctrl-char">
49
46
<term>
50
47
<constant>JSON_ERROR_CTRL_CHAR</constant>
51
-
(<type>integer</type>)
48
+
(<type>int</type>)
52
49
</term>
53
50
<listitem>
54
51
<simpara>
55
52
Control character error, possibly incorrectly encoded.
56
-
Available since PHP 5.3.0.
57
53
</simpara>
58
54
</listitem>
59
55
</varlistentry>
60
56
<varlistentry xml:id="constant.json-error-syntax">
61
57
<term>
62
58
<constant>JSON_ERROR_SYNTAX</constant>
63
-
(<type>integer</type>)
59
+
(<type>int</type>)
64
60
</term>
65
61
<listitem>
66
62
<simpara>
67
63
Syntax error.
68
-
Available since PHP 5.3.0.
69
64
</simpara>
70
65
</listitem>
71
66
</varlistentry>
72
67
<varlistentry xml:id="constant.json-error-utf8">
73
68
<term>
74
69
<constant>JSON_ERROR_UTF8</constant>
75
-
(<type>integer</type>)
70
+
(<type>int</type>)
76
71
</term>
77
72
<listitem>
78
73
<simpara>
79
74
Malformed UTF-8 characters, possibly incorrectly encoded.
80
-
Available since PHP 5.3.3.
81
75
</simpara>
82
76
</listitem>
83
77
</varlistentry>
84
78
<varlistentry xml:id="constant.json-error-recursion">
85
79
<term>
86
80
<constant>JSON_ERROR_RECURSION</constant>
87
-
(<type>integer</type>)
81
+
(<type>int</type>)
88
82
</term>
89
83
<listitem>
90
84
<simpara>
...
...
@@ -92,14 +86,13 @@
92
86
recursive references and cannot be encoded.
93
87
If the <constant>JSON_PARTIAL_OUTPUT_ON_ERROR</constant> option was
94
88
given, &null; will be encoded in the place of the recursive reference.
95
-
Available since PHP 5.5.0.
96
89
</simpara>
97
90
</listitem>
98
91
</varlistentry>
99
92
<varlistentry xml:id="constant.json-error-inf-or-nan">
100
93
<term>
101
94
<constant>JSON_ERROR_INF_OR_NAN</constant>
102
-
(<type>integer</type>)
95
+
(<type>int</type>)
103
96
</term>
104
97
<listitem>
105
98
<simpara>
...
...
@@ -109,49 +102,45 @@
109
102
If the <constant>JSON_PARTIAL_OUTPUT_ON_ERROR</constant> option was
110
103
given, <literal>0</literal> will be encoded in the place of these
111
104
special numbers.
112
-
Available since PHP 5.5.0.
113
105
</simpara>
114
106
</listitem>
115
107
</varlistentry>
116
108
<varlistentry xml:id="constant.json-error-unsupported-type">
117
109
<term>
118
110
<constant>JSON_ERROR_UNSUPPORTED_TYPE</constant>
119
-
(<type>integer</type>)
111
+
(<type>int</type>)
120
112
</term>
121
113
<listitem>
122
114
<simpara>
123
115
A value of an unsupported type was given to
124
-
<function>json_encode</function>, such as a <type>resource</type>.
116
+
<function>json_encode</function>, such as a &resource;.
125
117
If the <constant>JSON_PARTIAL_OUTPUT_ON_ERROR</constant> option was
126
118
given, &null; will be encoded in the place of the unsupported value.
127
-
Available since PHP 5.5.0.
128
119
</simpara>
129
120
</listitem>
130
121
</varlistentry>
131
122
<varlistentry xml:id="constant.json-error-invalid-property-name">
132
123
<term>
133
124
<constant>JSON_ERROR_INVALID_PROPERTY_NAME</constant>
134
-
(<type>integer</type>)
125
+
(<type>int</type>)
135
126
</term>
136
127
<listitem>
137
128
<simpara>
138
129
A key starting with \u0000 character was in the string passed to
139
130
<function>json_decode</function> when decoding a JSON object into a PHP
140
131
object.
141
-
Available since PHP 7.0.0.
142
132
</simpara>
143
133
</listitem>
144
134
</varlistentry>
145
135
<varlistentry xml:id="constant.json-error-utf16">
146
136
<term>
147
-
<constant>JSON_ERROR_INVALID_PROPERTY_NAME</constant>
148
-
(<type>integer</type>)
137
+
<constant>JSON_ERROR_UTF16</constant>
138
+
(<type>int</type>)
149
139
</term>
150
140
<listitem>
151
141
<simpara>
152
142
Single unpaired UTF-16 surrogate in unicode escape contained in the
153
-
JSON string passed to <function>json_encode</function>.
154
-
Available since PHP 7.0.0.
143
+
JSON string passed to <function>json_decode</function>.
155
144
</simpara>
156
145
</listitem>
157
146
</varlistentry>
...
...
@@ -165,26 +154,24 @@
165
154
<varlistentry xml:id="constant.json-bigint-as-string">
166
155
<term>
167
156
<constant>JSON_BIGINT_AS_STRING</constant>
168
-
(<type>integer</type>)
157
+
(<type>int</type>)
169
158
</term>
170
159
<listitem>
171
160
<simpara>
172
161
Decodes large integers as their original string value.
173
-
Available since PHP 5.4.0.
174
162
</simpara>
175
163
</listitem>
176
164
</varlistentry>
177
165
<varlistentry xml:id="constant.json-object-as-array">
178
166
<term>
179
167
<constant>JSON_OBJECT_AS_ARRAY</constant>
180
-
(<type>integer</type>)
168
+
(<type>int</type>)
181
169
</term>
182
170
<listitem>
183
171
<simpara>
184
172
Decodes JSON objects as PHP array. This option can be added automatically
185
173
by calling <function>json_decode</function> with the second parameter
186
174
equal to &true;.
187
-
Available since PHP 5.4.0.
188
175
</simpara>
189
176
</listitem>
190
177
</varlistentry>
...
...
@@ -198,157 +185,192 @@
198
185
<varlistentry xml:id="constant.json-hex-tag">
199
186
<term>
200
187
<constant>JSON_HEX_TAG</constant>
201
-
(<type>integer</type>)
188
+
(<type>int</type>)
202
189
</term>
203
190
<listitem>
204
191
<simpara>
205
192
All &lt; and &gt; are converted to \u003C and \u003E.
206
-
Available since PHP 5.3.0.
207
193
</simpara>
208
194
</listitem>
209
195
</varlistentry>
210
196
<varlistentry xml:id="constant.json-hex-amp">
211
197
<term>
212
198
<constant>JSON_HEX_AMP</constant>
213
-
(<type>integer</type>)
199
+
(<type>int</type>)
214
200
</term>
215
201
<listitem>
216
202
<simpara>
217
-
All &amp;s are converted to \u0026.
218
-
Available since PHP 5.3.0.
203
+
All &amp; are converted to \u0026.
219
204
</simpara>
220
205
</listitem>
221
206
</varlistentry>
222
207
<varlistentry xml:id="constant.json-hex-apos">
223
208
<term>
224
209
<constant>JSON_HEX_APOS</constant>
225
-
(<type>integer</type>)
210
+
(<type>int</type>)
226
211
</term>
227
212
<listitem>
228
213
<simpara>
229
214
All ' are converted to \u0027.
230
-
Available since PHP 5.3.0.
231
215
</simpara>
232
216
</listitem>
233
217
</varlistentry>
234
218
<varlistentry xml:id="constant.json-hex-quot">
235
219
<term>
236
220
<constant>JSON_HEX_QUOT</constant>
237
-
(<type>integer</type>)
221
+
(<type>int</type>)
238
222
</term>
239
223
<listitem>
240
224
<simpara>
241
225
All " are converted to \u0022.
242
-
Available since PHP 5.3.0.
243
226
</simpara>
244
227
</listitem>
245
228
</varlistentry>
246
229
<varlistentry xml:id="constant.json-force-object">
247
230
<term>
248
231
<constant>JSON_FORCE_OBJECT</constant>
249
-
(<type>integer</type>)
232
+
(<type>int</type>)
250
233
</term>
251
234
<listitem>
252
235
<simpara>
253
236
Outputs an object rather than an array when a non-associative array is
254
237
used. Especially useful when the recipient of the output is expecting
255
238
an object and the array is empty.
256
-
Available since PHP 5.3.0.
257
239
</simpara>
258
240
</listitem>
259
241
</varlistentry>
260
242
<varlistentry xml:id="constant.json-numeric-check">
261
243
<term>
262
244
<constant>JSON_NUMERIC_CHECK</constant>
263
-
(<type>integer</type>)
245
+
(<type>int</type>)
264
246
</term>
265
247
<listitem>
266
248
<simpara>
267
249
Encodes numeric strings as numbers.
268
-
Available since PHP 5.3.3.
269
250
</simpara>
270
251
</listitem>
271
252
</varlistentry>
272
253
<varlistentry xml:id="constant.json-pretty-print">
273
254
<term>
274
255
<constant>JSON_PRETTY_PRINT</constant>
275
-
(<type>integer</type>)
256
+
(<type>int</type>)
276
257
</term>
277
258
<listitem>
278
259
<simpara>
279
260
Use whitespace in returned data to format it.
280
-
Available since PHP 5.4.0.
281
261
</simpara>
282
262
</listitem>
283
263
</varlistentry>
284
264
<varlistentry xml:id="constant.json-unescaped-slashes">
285
265
<term>
286
266
<constant>JSON_UNESCAPED_SLASHES</constant>
287
-
(<type>integer</type>)
267
+
(<type>int</type>)
288
268
</term>
289
269
<listitem>
290
270
<simpara>
291
271
Don't escape <literal>/</literal>.
292
-
Available since PHP 5.4.0.
293
272
</simpara>
294
273
</listitem>
295
274
</varlistentry>
296
275
<varlistentry xml:id="constant.json-unescaped-unicode">
297
276
<term>
298
277
<constant>JSON_UNESCAPED_UNICODE</constant>
299
-
(<type>integer</type>)
278
+
(<type>int</type>)
300
279
</term>
301
280
<listitem>
302
281
<simpara>
303
282
Encode multibyte Unicode characters literally (default is to escape as
304
283
\uXXXX).
305
-
Available since PHP 5.4.0.
306
284
</simpara>
307
285
</listitem>
308
286
</varlistentry>
309
287
<varlistentry xml:id="constant.json-partial-output-on-error">
310
288
<term>
311
289
<constant>JSON_PARTIAL_OUTPUT_ON_ERROR</constant>
312
-
(<type>integer</type>)
290
+
(<type>int</type>)
313
291
</term>
314
292
<listitem>
315
293
<simpara>
316
294
Substitute some unencodable values instead of failing.
317
-
Available since PHP 5.5.0.
318
295
</simpara>
319
296
</listitem>
320
297
</varlistentry>
321
298
<varlistentry xml:id="constant.json-preserve-zero-fraction">
322
299
<term>
323
300
<constant>JSON_PRESERVE_ZERO_FRACTION</constant>
324
-
(<type>integer</type>)
301
+
(<type>int</type>)
325
302
</term>
326
303
<listitem>
327
304
<simpara>
328
-
Ensures that <type>float</type> values are always encoded as a float
329
-
value.
330
-
Available since PHP 5.6.6.
305
+
Ensures that &float; values are always encoded as a float value.
331
306
</simpara>
332
307
</listitem>
333
308
</varlistentry>
334
309
<varlistentry xml:id="constant.json-unescaped-line-terminators">
335
310
<term>
336
311
<constant>JSON_UNESCAPED_LINE_TERMINATORS</constant>
337
-
(<type>integer</type>)
312
+
(<type>int</type>)
338
313
</term>
339
314
<listitem>
340
315
<simpara>
341
316
The line terminators are kept unescaped when
342
317
<constant>JSON_UNESCAPED_UNICODE</constant> is supplied. It uses the same
343
318
behaviour as it was before PHP 7.1 without this constant.
344
-
Available since PHP 7.1.0.
319
+
Available as of PHP 7.1.0.
345
320
</simpara>
346
321
</listitem>
347
322
</varlistentry>
348
323
</variablelist>
349
324

350
-
</appendix>
325
+
<para>
326
+
The following constants can be combined to form options for
327
+
<function>json_decode</function> and <function>json_encode</function>.
328
+
</para>
329
+
<variablelist>
330
+
<varlistentry xml:id="constant.json-invalid-utf8-ignore">
331
+
<term>
332
+
<constant>JSON_INVALID_UTF8_IGNORE</constant>
333
+
(<type>int</type>)
334
+
</term>
335
+
<listitem>
336
+
<simpara>
337
+
Ignore invalid UTF-8 characters.
338
+
Available as of PHP 7.2.0.
339
+
</simpara>
340
+
</listitem>
341
+
</varlistentry>
342
+
<varlistentry xml:id="constant.json-invalid-utf8-substitute">
343
+
<term>
344
+
<constant>JSON_INVALID_UTF8_SUBSTITUTE</constant>
345
+
(<type>int</type>)
346
+
</term>
347
+
<listitem>
348
+
<simpara>
349
+
Convert invalid UTF-8 characters to \0xfffd
350
+
(Unicode Character 'REPLACEMENT CHARACTER')
351
+
Available as of PHP 7.2.0.
352
+
</simpara>
353
+
</listitem>
354
+
</varlistentry>
355
+
<varlistentry xml:id="constant.json-throw-on-error">
356
+
<term>
357
+
<constant>JSON_THROW_ON_ERROR</constant>
358
+
(<type>int</type>)
359
+
</term>
360
+
<listitem>
361
+
<simpara>
362
+
Throws <classname>JsonException</classname> if an error occurs instead
363
+
of setting the global error state that is retrieved with
364
+
<function>json_last_error</function> and <function>json_last_error_msg</function>.
365
+
<constant>JSON_PARTIAL_OUTPUT_ON_ERROR</constant> takes precedence over
366
+
<constant>JSON_THROW_ON_ERROR</constant>.
367
+
Available as of PHP 7.3.0.
368
+
</simpara>
369
+
</listitem>
370
+
</varlistentry>
371
+
</variablelist>
351
372

373
+
</appendix>
352
374
<!-- Keep this comment at the end of the file
353
375
Local variables:
354
376
mode: sgml
...
...
@@ -369,4 +391,3 @@ vim600: syn=xml fen fdm=syntax fdl=2 si
369
391
vim: et tw=78 syn=sgml
370
392
vi: ts=1 sw=1
371
393
-->
372
-

373
394