… | |
… | |
131 | |
131 | |
132 | Except being faster. |
132 | Except being faster. |
133 | |
133 | |
134 | =item $perl_scalar = decode_json $json_text |
134 | =item $perl_scalar = decode_json $json_text |
135 | |
135 | |
136 | The opposite of C<encode_json>: expects an UTF-8 (binary) string and tries |
136 | The opposite of C<encode_json>: expects a UTF-8 (binary) string and tries |
137 | to parse that as an UTF-8 encoded JSON text, returning the resulting |
137 | to parse that as a UTF-8 encoded JSON text, returning the resulting |
138 | reference. Croaks on error. |
138 | reference. Croaks on error. |
139 | |
139 | |
140 | This function call is functionally identical to: |
140 | This function call is functionally identical to: |
141 | |
141 | |
142 | $perl_scalar = JSON::XS->new->utf8->decode ($json_text) |
142 | $perl_scalar = JSON::XS->new->utf8->decode ($json_text) |
… | |
… | |
270 | |
270 | |
271 | =item $enabled = $json->get_utf8 |
271 | =item $enabled = $json->get_utf8 |
272 | |
272 | |
273 | If C<$enable> is true (or missing), then the C<encode> method will encode |
273 | If C<$enable> is true (or missing), then the C<encode> method will encode |
274 | the JSON result into UTF-8, as required by many protocols, while the |
274 | the JSON result into UTF-8, as required by many protocols, while the |
275 | C<decode> method expects to be handled an UTF-8-encoded string. Please |
275 | C<decode> method expects to be handed a UTF-8-encoded string. Please |
276 | note that UTF-8-encoded strings do not contain any characters outside the |
276 | note that UTF-8-encoded strings do not contain any characters outside the |
277 | range C<0..255>, they are thus useful for bytewise/binary I/O. In future |
277 | range C<0..255>, they are thus useful for bytewise/binary I/O. In future |
278 | versions, enabling this option might enable autodetection of the UTF-16 |
278 | versions, enabling this option might enable autodetection of the UTF-16 |
279 | and UTF-32 encoding families, as described in RFC4627. |
279 | and UTF-32 encoding families, as described in RFC4627. |
280 | |
280 | |
… | |
… | |
1289 | expect your input strings to be encoded as UTF-8, that is, no "character" |
1289 | expect your input strings to be encoded as UTF-8, that is, no "character" |
1290 | of the input string must have any value > 255, as UTF-8 does not allow |
1290 | of the input string must have any value > 255, as UTF-8 does not allow |
1291 | that. |
1291 | that. |
1292 | |
1292 | |
1293 | The C<utf8> flag therefore switches between two modes: disabled means you |
1293 | The C<utf8> flag therefore switches between two modes: disabled means you |
1294 | will get a Unicode string in Perl, enabled means you get an UTF-8 encoded |
1294 | will get a Unicode string in Perl, enabled means you get a UTF-8 encoded |
1295 | octet/binary string in Perl. |
1295 | octet/binary string in Perl. |
1296 | |
1296 | |
1297 | =item C<latin1> or C<ascii> flags enabled |
1297 | =item C<latin1> or C<ascii> flags enabled |
1298 | |
1298 | |
1299 | With C<latin1> (or C<ascii>) enabled, C<encode> will escape characters |
1299 | With C<latin1> (or C<ascii>) enabled, C<encode> will escape characters |