Egg::Release::JSON - JSON for Egg::Plugin.
Controller.
use Egg qw/ JSON /;
Example code.
my $json_data = { aaaaa => 'bbbbb', ccccc => 'ddddd', }; # # Mutual conversion of JSON data. # my $json_js = $e->obj2json($json_data); my $json_hash = $e->json2obj($json_js); # # The JSON module object is acquired. # my $json= $e->json;
It is a plugin to treat JSON.
JSON module is used. Please refer to the document of JSON for details.
It is wraper to the 'objToJson' function of JSON module.
HASH and ARRAY are given to JSON_DATA.
my $js= $e->obj2json($local_data);
It is wraper to the 'jsonToObj' function of "JSON " module.
The JSON data is given to JSON_JS.
my $local_data= $e->json2obj($json_js);
The object of JSON module is returned.
my $json= $e->json;
The JSON code is acquired by the file and URL and the Egg::Plugin::JSON::Result object is returned.
The occurrence of the error can be confirmed by is_success and the is_error method of the returned object.
* When URL is specified, the thing that Egg::Plugin::LWP can be used.
my $result= $e->get_json( GET=> 'http://domain/json_code' ); my $json_obj; if ($result->is_success and $json_obj= $result->obj) { $e->view->param('json_text', $json_obj->{message}); } else { $e->debug_out('JSON ERROR : '. $result->is_error); $e->finished(500); }
It is a method of Egg::Plugin::JSON::Result that get_json returns.
Constructor
When the data conversion of the obtained JSON code succeeds, true is restored.
Data returns when is_success is true.
The error message returns when is_success is false.
JSON, Egg::Release,
Masatoshi Mizuno <lushe@cpan.org>
Copyright (C) 2007 by Bee Flag, Corp. <http://egg.bomcity.com/>, All Rights Reserved.
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.6 or, at your option, any later version of Perl 5 you may have available.
1 POD Error
The following errors were encountered while parsing the POD:
L<> starts or ends with whitespace
To install Egg::Release::JSON, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Egg::Release::JSON
CPAN shell
perl -MCPAN -e shell install Egg::Release::JSON
For more information on module installation, please visit the detailed CPAN module installation guide.