sub add {
my ($self, $data) = @_;
if ($self->record_format eq 'MARC-in-JSON') {
$data = $self->_json_to_raw($data);
}
for my $field (@{$data->{record}}) {
my ($fiel
);
sub add {
my ($self, $data) = @_;
if ($self->record_format eq 'MARC-in-JSON') {
$data = $self->_json_to_raw($data);
}
for my $field (@{$data->{record}}) {
my ($fiel
=head1 NAME
Catmandu::Exporter::MARC::MiJ - Exporter for MARC records to MARC in JSON
=head1 SYNOPSIS
# From the command line
$ catmandu convert MARC --type XML to MARC --type MiJ < /foo/ba
le => "/foo/bar.xml" , type => 'XML');
my $exporter = Catmandu->exporter('MARC', file => "bar.json", type => 'MiJ' );
$exporter->add($importer);
$exporter->commit;
=head1 CONFIGURATION
tmandu::Counter>, and L<Catmandu::Logger> for a full list of methods.
=head1 FORMAT
The MARC-in-JSON record format contains two fields:
* 'leader' - the MARC leader
* 'fields' - an array of M
;
sub add {
my ($self,$data) = @_;
if ($self->record_format eq 'MARC-in-JSON') {
$data = $self->_json_to_raw($data);
}
my $id_str = $data->{_id};
$id_str =~ s{\D}{0}g
ata) = @_;
if (keys %$data) {
if ($self->record_format eq 'MARC-in-JSON') {
$data = $self->_json_to_raw($data);
}
if ($data->{$self->record}) {
my
nd1, $ind2, @data);
$marc->append_fields($field);
}
}
$marc;
}
sub _json_to_raw {
my ($self,$data) = @_;
my @record = ();
push (@record , [ 'LDR', ' ', ' ',
my $indent = $self->collection ? 1 : 0;
if ($self->record_format eq 'MARC-in-JSON') {
$data = $self->_json_to_raw($data);
}
if ($self->collection) {
$self->_line($indent,
record (default: 'record')
=item record_format
Optionally set to 'MARC-in-JSON' when the input format is in MARC-in-JSON
=item collection
add a marc:collection header when true (default: true)
=
or load custom MARC schema
my $validator = Catmandu::Validator::MARC->new( schema => 'schema.json' );
my $importer = Catmandu::Importer::MARC->new(
file => 't/camel.mrc',
ma.json')
=head1 DESCRIPTION
This L<Catmandu::Validator> can be used to check MARC records against an MARC21 schema. For more information see L<MARC::Schema> and L<"MARC21 structure in JSON"|h
ttps://pkiraly.github.io/2018/01/28/marc21-in-json/>.
See also L<Catmandu::Fix::validate>, and L<Catmandu::Fix::Condition::valid> for usage of validators in Catmandu Fix language.
=head1 CONFIGU
ckage that imports MARC-in-JSON records
=head1 SYNOPSIS
# From the command line
$ catmandu convert MARC --type MiJ --fix "marc_map('245a','title')" < /foo/bar.json
# From perl
use C
u;
# import records from file
my $importer = Catmandu->importer('MARC',file => '/foo/bar.json', type => 'MiJ');
my $fixer = Catmandu->fixer("marc_map('245a','title')");
$importer-
use Mojo::Base 'Mojo::Leds::Page';
use Mojo::Util qw(decamelize class_to_path);
use Mojo::JSON qw(decode_json);
has table => sub {
return decamelize(
( split( /\//, class_to_path( ref sh
3 ) if $c->ro;
my $rec = $c->_json_from_body;
return unless ($rec);
$rec = $c->_create($rec);
return unless ($rec);
$c->render_json( $c->_rec2json($rec) );
}
sub delete {
my $
n $c->_raise_error( 'Element not found', 404 ) unless $rec;
$c->_delete($rec);
$c->render_json( undef, 204 );
}
sub list {
my $c = shift;
my $query = $c->param('query');
retur
teral value
my $data = marc_set($data,'245[1]a', 'value');
# Set to a copy of a deeply nested JSON path
my $data = marc_set($data,'245[1]a', '$.my.deep.field');
=head1 DEPRECATED
This module
al value
my $data = marc_add($data, '245', a => 'value');
# Set to a copy of a deeply nested JSON path
my $data = marc_add($data, '245', a => '$.my.deep.field');
=head1 DEPRECATED
This modul
Package that imports MARC data
=head1 SYNOPSIS
# On the command line
# Convert MARC to JSON (default)
$ catmandu convert MARC < /foo/bar.mrc
# Convert MARC to MARC
$ catmandu c
or MARCMaker/MARCBreaker records
MiJ: L<Catmandu::Importer::MARC::MiJ> (MARC in JSON) - a parser for the MARC-in-JSON format
XML: L<Catmandu::Importer::MARC::XML> - a parser for the MARC XML forma
characters:
$ iconv -c -f UTF-8 -t UTF-8 marc21.utf8.raw | catmandu convert MARC --type RAW to JSON
=head2 Convert a decomposed UTF-8 file to a combined UTF-8 file and vice versa
For example, the
t
=head1 READING
=head2 Convert MARC21 records into JSON
The command below converts file data.mrc into JSON:
$ catmandu convert MARC to JSON < data.mrc
=head2 Convert MARC21 records into MARC-
onvert UNIMARC records into JSON, XML, ...
To read UNIMARC records use the RAW parser to get the correct character
encoding.
$ catmandu convert MARC --type RAW to JSON < data.mrc
$ catmandu co
8' forward_compatible => 1;
my $meta = CPAN::Meta->load_file('META.json'); # or META.yml
plan skip_all => 'No META.json' if ! $meta;
my @files = File::Find::Rule::Perl->perl_files->in('.
g_dep = $@;
}
die $missing_dep if $missing_dep;
my $meta;
for my $file (qw/ META.json META.yml /) {
if (-r $file) {
$tb->ok(1, "$file is present and readable");
}
}
if (! $meta) {
$tb->level(2);
$tb->ok(0, "Missing META.{yml,json} file for dependency checking");
$tb->diag("Use the non-legacy invocation to provide the
TY
our $VERSION = '0.011'; # VERSION
use Carp;
use File::Slurp;
use JSON::MaybeXS qw(decode_json encode_json);
use Crypt::PRNG;
use Net::SSH::Perl::Cipher;
use Blockchain::Ethereum::Keyst
ub id {
shift->{id};
}
sub private_key {
shift->{private_key};
}
sub _json {
return shift->{json} //= JSON::MaybeXS->new(utf8 => 1);
}
sub import_file {
my ($self, $file_path, $pass
word) = @_;
my $content = read_file($file_path);
my $decoded = $self->_json->decode(lc $content);
return $self->_from_object($decoded, $password);
}
sub _from_object {
my ($self, $o
=> 'integer',
is_nullable => 0,
is_numeric => 1,
},
);
sub TO_JSON {
return {
foo => $self->foo, # this becomes 0 instead of "0" due to context
}
}
use 5.016;
use warnings;
use Carp qw(croak carp);
use Date::Parse;
use Extism;
use JSON::PP qw(decode_json encode_json);
use LWP::UserAgent;
sub __request {
my ($self, $path, $opt) = @_;
$opt
$res->content
}
sub _json_request {
my ($self, $path, $opt) = @_;
$opt //= {};
if (exists $opt->{body}) {
$opt->{body} = eval {
encode_json($opt->{body})
};
to json\n";
}
$opt->{headers}{'Content-Type'} //= 'application/json; charset=utf-8';
}
my $res = $self->__request($path, $opt);
my $content = eval {
decode_json($r
rmat );
$s->respond_to(
html => sub { $s->render_pm },
json => sub { $s->render( json => $s->render_json ) },
css => sub { $s->render_static_file },
js => sub {
ly->not_found;
}
sub render_html {
my $c = shift;
# needed for recursive calls (html -> json as an example)
my $query = $c->req->params->to_hash;
while ( my ( $k, $v ) = each %$query
$k => $v );
}
return { template => class_to_path( ref($c) ) =~ s/\.pm//r };
}
sub render_json {
my $c = shift;
return {};
}
sub render_static_file {
my $c = shift;
# optiona
ror( 'Element duplicated', 409 )
unless ( $rec->in_storage );
return $rec;
}
sub _rec2json() {
my $c = shift;
my $rec = shift || $c->stash( $c->_class_name . '::record' );
re
ec);
# annullo tutti i campi
$rec->$_(undef) foreach ( grep !/^${pk}$/, keys %{ $c->_rec2json } );
while ( my ( $k, $v ) = each %$set ) {
$rec->$k($v);
}
$rec->update;
$c->_rec2json($_);
}
if ($rc) {
$recs = { count => $rec->pager->total_entries, recs => $recs };
}
return $recs;
}
sub _listupdate {
my $c = shift;
my $json = shift