Data::AnyXfer::JSON - functions for encoding/decoding JSON
use utf8; # source code contains UTF-8 use Data::AnyXfer::JSON qw/ decode_json /; my $json = encode_json( { price => '£185pcm' } ); my $hash = decode_json( $json );
This module provides simple wrappers around Cpanel::JSON::XS that ensure JSON strings are encoded as UTF-8 before decoding them.
encode_json
my $json = encode_json( { price => '£185pcm' } );
Return UTF-8 encoded JSON.
encode_json_pretty
my $json = encode_json_pretty( { price => '£185pcm' } );
Return UTF-8 encoded multi-line formatted / pretty JSON.
decode_json
my $hash = decode_json( $json );
Decode a JSON string. Automatically encodes it to UTF-8.
decode_json_file
my $hash = decode_json_file( $json_file );
Decode the contents of a file as a JSON string.
Automatically encodes it to UTF-8.
decode_json_handle
my $hash = decode_json_handle( $json_fh );
Decode the contents of a file handle as a JSON string.
is_bool
true
false
See Cpanel::JSON::XS.
This software is copyright (c) 2019, Anthony Lucas.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Data::AnyXfer, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::AnyXfer
CPAN shell
perl -MCPAN -e shell install Data::AnyXfer
For more information on module installation, please visit the detailed CPAN module installation guide.