package Sisimai::Data::JSON;
use feature ':5.10';
use strict;
use warnings;
use JSON;
sub dump {
# Data dumper(JSON)
# @param [Sisimai::Data] argvs Object
# @return [String, Undef]
my $jsonstring = '';
eval { $jsonstring = JSON->new->space_after(1)->encode($argvs->damn) };
warn sprintf(" ***warning: Something is wrong in JSON encoding: %s", $@) if $@;
return $jsonstr
ing;
}
1;
__END__
=encoding utf-8
=head1 NAME
Sisimai::Data::JSON - Dumps parsed data object as a JSON format
=head1 SYNOPSIS
use Sisimai::Data;
my $data = Sisimai::Data->make('data' =>
package Sisimai::Fact::JSON;
use v5.26;
use strict;
use warnings;
use JSON;
sub dump {
# Data dumper(JSON)
# @param [Sisimai::Fact] argvs Object
# @return [String] D
my $jsonstring = "";
eval { $jsonstring = JSON->new->space_after(1)->encode($argvs->damn) };
warn sprintf(" ***warning: Something is wrong in JSON encoding: %s", $@) if $@;
return $jsonstr
ing;
}
1;
__END__
=encoding utf-8
=head1 NAME
Sisimai::Fact::JSON - Dumps decoded data object as a JSON format
=head1 SYNOPSIS
use Sisimai::Fact;
my $fact = Sisimai::Fact->rise('data' =>
] argv0 Path to mbox or Maildir/
# @param [Hash] argv0 or Hash (decoded JSON)
# @param [Handle] argv0 or STDIN
# @param [Hash] argv1 Opt
code mailbox/Maildir and dump as JSON
# @param [String] argv0 Path to mbox or Maildir/
# @param [Hash] argv0 or Hash (decoded JSON)
# @param [Handle]
Code reference to a callback method
# @return [String] Decoded data as JSON text
my $class = shift;
my $argv0 = shift // return undef; die ' ***error: wrong number o
mai::Time;
use parent 'Time::Piece';
use v5.26;
use strict;
use warnings;
sub TO_JSON {
# Instance method for JSON::encode()
# @return [Integer] Machine time
my $self = shift;
retur
pecific headers in the bounce mail headers such as C<X-Failed-Recipients:>, which MTA modules
for JSON structure.
=head1 CLASS METHODS
=head2 C<B<another()>>
C<another()> method returns another lis
[String] type Data format: json, yaml
# @return [String, Undef] Dumped data or Undef if the value of first
# argument is neither "json" nor "yaml"
my $self =
shift;
my $type = shift || 'json';
return undef unless $type =~ /\A(?:json|yaml)\z/;
my $referclass = 'Sisimai::Data::'.uc($type);
my $modulepath = 'Sisimai/Data/'.uc($type).'.pm';
isimai::Address> object generated from the sender address.
When Sisimai::Data object is dumped as JSON, this value converted to an email
address. Sisimai::Address object have the following accessors:
etect an error from Amazon SES
# @param [Hash] mhead Message headers of a bounce email (JSON)
# @param [String] mbody Message body of a bounce email
# @return [Hash] B
//g;
my $p2 = index($sespayload, '"Message"');
if( $p2 > 0 ) {
# The JSON included in the email is a format like the following:
# {
# "Type" : "No
# Load as JSON string and decode
require JSON;
my $jsonobject = undef; eval { $jsonobject = JSON->new->decode($sespayload) };
if( $@ ) {
# Something wrong in decoding JSON
unless $local[0] =~ /\A([-_\w]+?)[+].+\z/;
return $1.'@'.$local[1];
}
sub TO_JSON {
# Instance method for JSON::encode()
# @return [String] The value of "address" accessor
my $self
Data format: json, yaml
# @return [String] Dumped data or an empty string when the argument is neither "json" nor "yaml"
my $self = shift;
my $type = shift || 'json'; return "" u
nless $type =~ /\A(?:json|yaml)\z/;
my $referclass = 'Sisimai::Fact::'.uc($type);
my $modulepath = 'Sisimai/Fact/'.uc($type).'.pm';
require $modulepath;
return $referclass->dump($sel
mai::Address> object generated from the sender address. When C<Sisimai::Fact>
object is dumped as JSON, this value converted to an email address. C<Sisimai::Address> object have
the following accessor