Business::CAMT->new;
my $msg = $camt->read($file|$xml);
print $msg->toPerl;
print $msg->toJSON;
my $message = $camt->create('053.001.02', $data);
$camt->write('out.xml', $message);
$mes
T::Message|Business::CAMT::Message>)
to a file in XML format. The message can also be written as JSON or Perl
data-structure, via the message itself.
ยป example: writing a message
my $message = $
the "interface" which these messages implement a lot.
Done this way, XML is not much better than JSON. To be honest, the
schemas are littered by missed chances.
The messages are designed with an UM
.);
$msg->write('file.xml');
print $msg->toPerl;
open my $fh, '>:raw', 'msg.json' and $fh->print($msg->toJSON);
=head1 DESCRIPTION
This module is the base class for objects which are able to
=item $obj-E<gt>B<version>()
Z<>
=back
=head2 Other
=over 4
=item $obj-E<gt>B<toJSON>(%options)
Returns JSON raw text (bytes, not characters) for the data. You may
save this to a file (explici
ettings {pretty => 1, canonical => 1}
=over 2
=item settings => HASH
Pass the settings to the JSON generator object, see its manual page.
Provided settings will overrule the defaults.
=encoding u
}
use strict;
use warnings;
use Log::Report 'business-camt';
use Scalar::Util qw/weaken/;
use JSON ();
sub new
{ my ($class, %args) = @_;
my $data = delete $args{data} or return undef;
(1)->Quotekeys(0)->Indent(1);
my $text = $d->Dump;
$self->{_attrs} = $attrs;
$text;
}
sub toJSON(%)
{ my ($self, %args) = @_;
my %data = %$self; # Shallow copy to remove blessing
delet
$settings);
# JSON parameters call methods, copied from to_json behavior
my $json = JSON->new;
while(my ($method, $value) = each %settings)
{ $json->$method($value);
}
$json->encode(\%data