The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Egg::Release::JSON - JSON for Egg::Plugin.

SYNOPSIS

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;

DESCRIPTION

It is a plugin to treat JSON.

JSON module is used. Please refer to the document of JSON for details.

METHODS

obj2json ( [JSON_DATA] )

It is wraper to the 'objToJson' function of JSON module.

HASH and ARRAY are given to JSON_DATA.

  my $js= $e->obj2json($local_data);

json2obj ( [JSON_JS] )

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);

json

The object of JSON module is returned.

  my $json= $e->json;

get_json ( [FILE_PATH] || [REQUEST_METHOD], [URL], [LWP_OPTION])

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);
  }

RESULT METHODS

It is a method of Egg::Plugin::JSON::Result that get_json returns.

new

Constructor

is_success

When the data conversion of the obtained JSON code succeeds, true is restored.

obj

Data returns when is_success is true.

is_error

The error message returns when is_success is false.

SEE ALSO

JSON, Egg::Release,

AUTHOR

Masatoshi Mizuno <lushe@cpan.org>

COPYRIGHT

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:

Around line 65:

L<> starts or ends with whitespace