… | |
… | |
429 | |
429 | |
430 | =item $json = $json->allow_nonref ([$enable]) |
430 | =item $json = $json->allow_nonref ([$enable]) |
431 | |
431 | |
432 | =item $enabled = $json->get_allow_nonref |
432 | =item $enabled = $json->get_allow_nonref |
433 | |
433 | |
434 | Unlike other boolean options, this opotion is enabled by default beginning |
434 | Unlike other boolean options, this option is enabled by default beginning |
435 | with version C<4.0>. See L<SECURITY CONSIDERATIONS> for the gory details. |
435 | with version C<4.0>. See L<SECURITY CONSIDERATIONS> for the gory details. |
436 | |
436 | |
437 | If C<$enable> is true (or missing), then the C<encode> method can convert a |
437 | If C<$enable> is true (or missing), then the C<encode> method can convert a |
438 | non-reference into its corresponding string, number or null JSON value, |
438 | non-reference into its corresponding string, number or null JSON value, |
439 | which is an extension to RFC4627. Likewise, C<decode> will accept those JSON |
439 | which is an extension to RFC4627. Likewise, C<decode> will accept those JSON |
… | |
… | |
1193 | In this case, the C<TO_JSON> method of the object is invoked in scalar |
1193 | In this case, the C<TO_JSON> method of the object is invoked in scalar |
1194 | context. It must return a single scalar that can be directly encoded into |
1194 | context. It must return a single scalar that can be directly encoded into |
1195 | JSON. This scalar replaces the object in the JSON text. |
1195 | JSON. This scalar replaces the object in the JSON text. |
1196 | |
1196 | |
1197 | For example, the following C<TO_JSON> method will convert all L<URI> |
1197 | For example, the following C<TO_JSON> method will convert all L<URI> |
1198 | objects to JSON strings when serialised. The fatc that these values |
1198 | objects to JSON strings when serialised. The fact that these values |
1199 | originally were L<URI> objects is lost. |
1199 | originally were L<URI> objects is lost. |
1200 | |
1200 | |
1201 | sub URI::TO_JSON { |
1201 | sub URI::TO_JSON { |
1202 | my ($uri) = @_; |
1202 | my ($uri) = @_; |
1203 | $uri->as_string |
1203 | $uri->as_string |