Lines 358-371
sub json2marc {
Link Here
|
358 |
|
358 |
|
359 |
# fields are like: |
359 |
# fields are like: |
360 |
# [ '245', '1', '2', 'a' => 'Title', 'b' => 'Subtitle' ] |
360 |
# [ '245', '1', '2', 'a' => 'Title', 'b' => 'Subtitle' ] |
|
|
361 |
# or |
362 |
# [ '001', undef, undef, '_', 'a value' ] |
361 |
# conveniently, this is the form that MARC::Field->new() likes |
363 |
# conveniently, this is the form that MARC::Field->new() likes |
362 |
foreach my $field (@$marcjson) { |
364 |
foreach my $field (@$marcjson) { |
363 |
next if @$field < 5; # Shouldn't be possible, but... |
365 |
next if @$field < 5; |
364 |
if ( $field->[0] eq 'LDR' ) { |
366 |
if ( $field->[0] eq 'LDR' ) { |
365 |
$marc->leader( $field->[4] ); |
367 |
$marc->leader( $field->[4] ); |
366 |
} |
368 |
} |
367 |
else { |
369 |
else { |
368 |
my $marc_field = MARC::Field->new(@$field); |
370 |
my $tag = $field->[0]; |
|
|
371 |
my $marc_field; |
372 |
if ( MARC::Field->is_controlfield_tag( $field->[0] ) ) { |
373 |
$marc_field = MARC::Field->new($field->[0], $field->[4]); |
374 |
} else { |
375 |
$marc_field = MARC::Field->new(@$field); |
376 |
} |
369 |
$marc->append_fields($marc_field); |
377 |
$marc->append_fields($marc_field); |
370 |
} |
378 |
} |
371 |
} |
379 |
} |
372 |
- |
|
|