I think it's a mistake to get hung up on the leader being "next to" the
fields or the indicators being "next to" the subfields. The leader and
indicators aren't really different than fields and subfields. They were
given special treatment in ISO 2709 due to the limitations of ISO 2709.
If we're moving forward, we shouldn't pull those anachronistic
distinctions forward with us.

But other than that, 6 of one, half dozen of another ...

/dev

-- 
Devon Smith
Consulting Software Engineer
OCLC Research
http://www.oclc.org/research/people/smith.htm


-----Original Message-----
From: Dueber, William [mailto:dueb...@umich.edu] 
Sent: Tuesday, January 18, 2011 9:57 AM
To: Brad Baxter; Galen Charlton
Cc: perl4lib
Subject: Re: MARC-in-JSON in MARC::Record

I like the fact that it's slightly less verbose, but am put off by the
fact that it mixes different semantic entities in the same arrays. The
leader is "next to" the fields; the indicators are "next to" the
subfields.  E.g., in the variable field:

  { "010" :
    [
    { "ind1": " " },
    { "ind2": " " },
    { "a"   : "68009499" }
    ]

...there's no easy way to get at the indicators, unless we force the
indicators to always come first - a restriction which isn't onerous, but
needn't be there in the semantic sense since the indicators are
different sorts of things than the subfields.

Even with that restriction, it's a little confusing to get an iterator
over the subfields.

 foreach my $sf (@{$field->[1]}) {
    next if ($sf->[0] =~ /^ind[12]$/);
    ...
  }

I supposed we could take a slice, e.g., @{$field->[1]}[2..-1] (is that
even legal perl?) but I would claim it's  not as readable as the
marc-in-json equivalent:

 my $ind1 = $field->{ind1};
  foreach my $sf (@{$field->{subfields}}) { ...}


(It also seems, at first glance, to be harder to write
JSONPath/JSONQuery queries for this structure - at least ones that I
could read later - although I'm not very familiar with those
technologies).

Just for comparison, the same record as below in JSON and YAML:

JSON:
{
  "leader" : "leader string",
  "fields":
  [
    { "001" : "001 value" },
    { "002" : "002 value" },
    { "010" :
      {
        "ind1": " ",
        "ind2": " ",
        "subfields": [
          { "a"   : "68009499" }
        ]
      },
    },
    { "035" :
      {
        "ind1": " ",
        "ind2": " ",
        "subfields": [
          { "a"   : "(RLIN)MIUG0000733-B" }
        ]
      },
    },
    { "035" :
      {
        "ind1": " ",
        "ind2": " ",
        "subfields": [
          { "a"   : "(CaOTULAS)159818014" }
        ]
      },
    },
    { "245" :
      {
        "ind1": "1",
        "ind2": "0",
        "subfields": [
        { "a"   : "Capitalism, primitive and modern;" }
        { "b"   : "some aspects of Tolai economic growth" }
        { "c"   : "[by] T. Scarlett Epstein." }
        ]
      },
    }
  ]
}

YAML (complements of json_xs!)

leader: leader string
fields:
  - 001: 001 value
  - 002: 002 value
  - 010:
      ind1: ' '
      ind2: ' '
      subfields:
        - a: 68009499
  - 035:
      ind1: ' '
      ind2: ' '
      subfields:
        - a: (RLIN)MIUG0000733-B
  - 035:
      ind1: ' '
      ind2: ' '
      subfields:
        - a: (CaOTULAS)159818014
  - 245:
      ind1: 1
      ind2: 0
      subfields:
        - a: 'Capitalism, primitive and modern;'
        - b: some aspects of Tolai economic growth
        - c: '[by] T. Scarlett Epstein.'





On 1/18/11 9:14 AM, "Brad Baxter" <b...@mail.libs.uga.edu> wrote:

When I wrote Data::Pairs (http://search.cpan.org/dist/Data-Pairs/), I
had
JSONified MARC in mind.  To my mind, a data structure that is a "Pairs
of Pairs"[2] would faithfully represent a MARC record, including
preserving
the orders of fields/subfields.

Below is the short example from [1] displayed as a Pairs of Pairs in
JSON.  In Data::Pairs, I wanted to see what the algorithms might be
for setting and getting data from such a structure, with the intention
that those algorithms might be the basis for a similar JSON library.

So my real world situation isn't that I've used any MARC in JSON to
date, but I did begin writing code with that intention.  :-)

Appearing after the JSON example below is the same data displayed
as YAML.  By taking the Pairs of Pairs approach, I had envisioned that
presenting the YAML version to a human might facilitate manual edits.

I guess I'm late in the game suggesting another proposal, but there it
is.  Writing a schema for this might be tricky, but as a data structure
it's fairly simple and self-consistent.

Regards,

Brad

[1] http://robotlibrarian.billdueber.com/new-interest-in-marc-hash-json/
[2] http://yaml.org/type/pairs.html

JSON:

[
{ "leader" : "leader string" },
{ "001" : "001 value" },
{ "002" : "002 value" },
{ "010" :
    [
    { "ind1": " " },
    { "ind2": " " },
    { "a"   : "68009499" }
    ]
}
{ "035" :
    [
    { "ind1": " " },
    { "ind2": " " },
    { "a"   : "(RLIN)MIUG0000733-B" },
    ]
}
{ "035" :
    [
    { "ind1": " " },
    { "ind2": " " },
    { "a"   : "(CaOTULAS)159818014" },
    ]
}
{ "245" :
    [
    { "ind1": "1" },
    { "ind2": "0" },
    { "a"   : "Capitalism, primitive and modern;" },
    { "b"   : "some aspects of Tolai economic growth" },
    { "c"   : "[by] T. Scarlett Epstein." }
    ]
}
]

YAML:

- leader: "leader string"
- 001: "001 value"
- 002: "002 value"
- 010:
  - ind1: " "
  - ind2: " "
  - a: "68009499:
- 035:
  - ind1: " "
  - ind2: " "
  - a: "(RLIN)MIUG0000733-B"
- 035:
  - ind1: " "
  - ind2: " "
  - a: "(CaOTULAS)159818014"
- 245:
  - ind1: "1"
  - ind2: "0"
  - a: "Capitalism, primitive and modern;"
  - b: "some aspects of Tolai economic growth"
  - c: "[by] T. Scarlett Epstein."


--
Bill Dueber
Library Systems Programmer
University Library, University of Michigan
734.615.0412

Reply via email to