{"id":411,"date":"2010-09-02T14:07:58","date_gmt":"2010-09-02T19:07:58","guid":{"rendered":"http:\/\/dilettantes.code4lib.org\/blog\/?p=411"},"modified":"2010-09-02T14:26:20","modified_gmt":"2010-09-02T19:26:20","slug":"a-proposal-to-serialize-marc-in-json","status":"publish","type":"post","link":"https:\/\/rossfsinger.me\/blog\/2010\/09\/a-proposal-to-serialize-marc-in-json\/","title":{"rendered":"A Proposal to serialize MARC in JSON"},"content":{"rendered":"<blockquote><p>Note: to see the backstory and justification of this proposal, <a href=\"\/blog\/2010\/09\/for-your-consideration-yet-another-marc-in-json-proposal-pt-1\">please see the preceding post<\/a>.<\/p><\/blockquote>\n<p>MARC-in-JSON is a proposed <a href=\"http:\/\/json.org\/\">JSON<\/a> schema for representing <a href=\"http:\/\/www.loc.gov\/marc\/specifications\/\">MARC<\/a> records as JSON.  It is the outgrowth of working with MARC data in MongoDB and is intended to be both a faithful representation of MARC as well as a logical and useful model to work natively in JSON-centric environments.  Ideally, this serialization could eventually replace binary MARC as the default format.   The round trip of a MARC-in-JSON record from MARC to JSON back to MARC is lossless and preserves field\/subfield order.<\/p>\n<p>An example <a href=\"http:\/\/lccn.loc.gov\/93707283\/marcxml\">MARC bibliographic record<\/a>, represented as text:<br \/>\n<code><br \/>\nLEADER 01471cjm a2200349 a 4500<br \/>\n001 5674874<br \/>\n005 20030305110405.0<br \/>\n007 sdubsmennmplu<br \/>\n008 930331s1963    nyuppn              eng d<br \/>\n035    $9 (DLC)   93707283<br \/>\n906    $a 7 $b cbc $c copycat $d 4 $e ncip $f 19 $g y-soundrec<br \/>\n010    $a    93707283<br \/>\n028 02 $a CS 8786 $b Columbia<br \/>\n035    $a (OCoLC)13083787<br \/>\n040    $a OClU $c DLC $d DLC<br \/>\n041 0  $d eng $g eng<br \/>\n042    $a lccopycat<br \/>\n050 00 $a Columbia CS 8786<br \/>\n100 1  $a Dylan, Bob, $d 1941-<br \/>\n245 14 $a The freewheelin' Bob Dylan $h [sound recording].<br \/>\n260    $a [New York, N.Y.] : $b Columbia, $c [1963]<br \/>\n300    $a 1 sound disc : $b analog, 33 1\/3 rpm, stereo. ; $c 12 in.<br \/>\n500    $a Songs.<br \/>\n511 0  $a The composer accompanying himself on the guitar ; in part with instrumental ensemble.<br \/>\n500    $a Program notes by Nat Hentoff on container.<br \/>\n505 0  $a Blowin' in the wind -- Girl from the north country -- Masters of war -- Down the highway -- Bob Dylan's blues -- A hard rain's a-gonna fall -- Don't think twice, it's all right -- Bob Dylan's dream -- Oxford town -- Talking World War III blues -- Corrina, Corrina -- Honey, just allow me one more chance -- I shall be free.<br \/>\n650  0 $a Popular music $y 1961-1970.<br \/>\n650  0 $a Blues (Music) $y 1961-1970.<br \/>\n856 41 $3 Preservation copy (limited access) $u http:\/\/hdl.loc.gov\/loc.mbrsrs\/lp0001.dyln<br \/>\n952    $a New<br \/>\n953    $a TA28<br \/>\n991    $b c-RecSound $h Columbia CS 8786 $w MUSIC<br \/>\n<\/code><\/p>\n<p>The same bibliographic record serialized as MARC-in-JSON would appear as follows (pretty-printed with whitespace and line breaks for readability):<\/p>\n<pre>{\r\n    \"leader\":\"01471cjm a2200349 a 4500\",\r\n    \"fields\":\r\n    [\r\n        {\r\n            \"001\":\"5674874\"\r\n        },\r\n        {\r\n            \"005\":\"20030305110405.0\"\r\n        },\r\n        {\r\n            \"007\":\"sdubsmennmplu\"\r\n        },\r\n        {\r\n            \"008\":\"930331s1963    nyuppn              eng d\"\r\n        },\r\n        {\r\n            \"035\":\r\n            {\r\n                \"subfields\":\r\n                [\r\n                    {\r\n                        \"9\":\"(DLC)   93707283\"\r\n                    }\r\n                ],\r\n                \"ind1\":\" \",\r\n                \"ind2\":\" \"\r\n            }\r\n        },\r\n        {\r\n            \"906\":\r\n            {\r\n                \"subfields\":\r\n                [\r\n                    {\r\n                        \"a\":\"7\"\r\n                    },\r\n                    {\r\n                        \"b\":\"cbc\"\r\n                    },\r\n                    {\r\n                        \"c\":\"copycat\"\r\n                    },\r\n                    {\r\n                        \"d\":\"4\"\r\n                    },\r\n                    {\r\n                        \"e\":\"ncip\"\r\n                    },\r\n                    {\r\n                        \"f\":\"19\"\r\n                    },\r\n                    {\r\n                        \"g\":\"y-soundrec\"\r\n                    }\r\n                ],\r\n                \"ind1\":\" \",\r\n                \"ind2\":\" \"\r\n            }\r\n        },\r\n        {\r\n            \"010\":\r\n            {\r\n                \"subfields\":\r\n                [\r\n                    {\r\n                        \"a\":\"   93707283 \"\r\n                    }\r\n                ],\r\n                \"ind1\":\" \",\r\n                \"ind2\":\" \"\r\n            }\r\n        },\r\n        {\r\n            \"028\":\r\n            {\r\n                \"subfields\":\r\n                [\r\n                    {\r\n                        \"a\":\"CS 8786\"\r\n                    },\r\n                    {\r\n                        \"b\":\"Columbia\"\r\n                    }\r\n                ],\r\n                \"ind1\":\"0\",\r\n                \"ind2\":\"2\"\r\n            }\r\n        },\r\n        {\r\n            \"035\":\r\n            {\r\n                \"subfields\":\r\n                [\r\n                    {\r\n                        \"a\":\"(OCoLC)13083787\"\r\n                    }\r\n                ],\r\n                \"ind1\":\" \",\r\n                \"ind2\":\" \"\r\n            }\r\n        },\r\n        {\r\n            \"040\":\r\n            {\r\n                \"subfields\":\r\n                [\r\n                    {\r\n                        \"a\":\"OClU\"\r\n                    },\r\n                    {\r\n                        \"c\":\"DLC\"\r\n                    },\r\n                    {\r\n                        \"d\":\"DLC\"\r\n                    }\r\n                ],\r\n                \"ind1\":\" \",\r\n                \"ind2\":\" \"\r\n            }\r\n        },\r\n        {\r\n            \"041\":\r\n            {\r\n                \"subfields\":\r\n                [\r\n                    {\r\n                        \"d\":\"eng\"\r\n                    },\r\n                    {\r\n                        \"g\":\"eng\"\r\n                    }\r\n                ],\r\n                \"ind1\":\"0\",\r\n                \"ind2\":\" \"\r\n            }\r\n        },\r\n        {\r\n            \"042\":\r\n            {\r\n                \"subfields\":\r\n                [\r\n                    {\r\n                        \"a\":\"lccopycat\"\r\n                    }\r\n                ],\r\n                \"ind1\":\" \",\r\n                \"ind2\":\" \"\r\n            }\r\n        },\r\n        {\r\n            \"050\":\r\n            {\r\n                \"subfields\":\r\n                [\r\n                    {\r\n                        \"a\":\"Columbia CS 8786\"\r\n                    }\r\n                ],\r\n                \"ind1\":\"0\",\r\n                \"ind2\":\"0\"\r\n            }\r\n        },\r\n        {\r\n            \"100\":\r\n            {\r\n                \"subfields\":\r\n                [\r\n                    {\r\n                        \"a\":\"Dylan,\r\n                         Bob,\r\n                        \"\r\n                    },\r\n                    {\r\n                        \"d\":\"1941-\"\r\n                    }\r\n                ],\r\n                \"ind1\":\"1\",\r\n                \"ind2\":\" \"\r\n            }\r\n        },\r\n        {\r\n            \"245\":\r\n            {\r\n                \"subfields\":\r\n                [\r\n                    {\r\n                        \"a\":\"The freewheelin' Bob Dylan\"\r\n                    },\r\n                    {\r\n                        \"h\":\"\r\n                        [\r\n                            sound recording\r\n                        ]\r\n                        .\"\r\n                    }\r\n                ],\r\n                \"ind1\":\"1\",\r\n                \"ind2\":\"4\"\r\n            }\r\n        },\r\n        {\r\n            \"260\":\r\n            {\r\n                \"subfields\":\r\n                [\r\n                    {\r\n                        \"a\":\"\r\n                        [\r\n                            New York,\r\n                             N.Y.\r\n                        ]\r\n                         :\"\r\n                    },\r\n                    {\r\n                        \"b\":\"Columbia,\r\n                        \"\r\n                    },\r\n                    {\r\n                        \"c\":\"\r\n                        [\r\n                            1963\r\n                        ]\r\n                        \"\r\n                    }\r\n                ],\r\n                \"ind1\":\" \",\r\n                \"ind2\":\" \"\r\n            }\r\n        },\r\n        {\r\n            \"300\":\r\n            {\r\n                \"subfields\":\r\n                [\r\n                    {\r\n                        \"a\":\"1 sound disc :\"\r\n                    },\r\n                    {\r\n                        \"b\":\"analog,\r\n                         33 1\/3 rpm,\r\n                         stereo. ;\"\r\n                    },\r\n                    {\r\n                        \"c\":\"12 in.\"\r\n                    }\r\n                ],\r\n                \"ind1\":\" \",\r\n                \"ind2\":\" \"\r\n            }\r\n        },\r\n        {\r\n            \"500\":\r\n            {\r\n                \"subfields\":\r\n                [\r\n                    {\r\n                        \"a\":\"Songs.\"\r\n                    }\r\n                ],\r\n                \"ind1\":\" \",\r\n                \"ind2\":\" \"\r\n            }\r\n        },\r\n        {\r\n            \"511\":\r\n            {\r\n                \"subfields\":\r\n                [\r\n                    {\r\n                        \"a\":\"The composer accompanying himself on the guitar ; in part with instrumental ensemble.\"\r\n                    }\r\n                ],\r\n                \"ind1\":\"0\",\r\n                \"ind2\":\" \"\r\n            }\r\n        },\r\n        {\r\n            \"500\":\r\n            {\r\n                \"subfields\":\r\n                [\r\n                    {\r\n                        \"a\":\"Program notes by Nat Hentoff on container.\"\r\n                    }\r\n                ],\r\n                \"ind1\":\" \",\r\n                \"ind2\":\" \"\r\n            }\r\n        },\r\n        {\r\n            \"505\":\r\n            {\r\n                \"subfields\":\r\n                [\r\n                    {\r\n                        \"a\":\"Blowin' in the wind -- Girl from the north country -- Masters of war -- Down the highway -- Bob Dylan's blues -- A hard rain's a-gonna fall -- Don't think twice,\r\n                         it's all right -- Bob Dylan's dream -- Oxford town -- Talking World War III blues -- Corrina,\r\n                         Corrina -- Honey,\r\n                         just allow me one more chance -- I shall be free.\"\r\n                    }\r\n                ],\r\n                \"ind1\":\"0\",\r\n                \"ind2\":\" \"\r\n            }\r\n        },\r\n        {\r\n            \"650\":\r\n            {\r\n                \"subfields\":\r\n                [\r\n                    {\r\n                        \"a\":\"Popular music\"\r\n                    },\r\n                    {\r\n                        \"y\":\"1961-1970.\"\r\n                    }\r\n                ],\r\n                \"ind1\":\" \",\r\n                \"ind2\":\"0\"\r\n            }\r\n        },\r\n        {\r\n            \"650\":\r\n            {\r\n                \"subfields\":\r\n                [\r\n                    {\r\n                        \"a\":\"Blues (Music)\"\r\n                    },\r\n                    {\r\n                        \"y\":\"1961-1970.\"\r\n                    }\r\n                ],\r\n                \"ind1\":\" \",\r\n                \"ind2\":\"0\"\r\n            }\r\n        },\r\n        {\r\n            \"856\":\r\n            {\r\n                \"subfields\":\r\n                [\r\n                    {\r\n                        \"3\":\"Preservation copy (limited access)\"\r\n                    },\r\n                    {\r\n                        \"u\":\"http:\/\/hdl.loc.gov\/loc.mbrsrs\/lp0001.dyln\"\r\n                    }\r\n                ],\r\n                \"ind1\":\"4\",\r\n                \"ind2\":\"1\"\r\n            }\r\n        },\r\n        {\r\n            \"952\":\r\n            {\r\n                \"subfields\":\r\n                [\r\n                    {\r\n                        \"a\":\"New\"\r\n                    }\r\n                ],\r\n                \"ind1\":\" \",\r\n                \"ind2\":\" \"\r\n            }\r\n        },\r\n        {\r\n            \"953\":\r\n            {\r\n                \"subfields\":\r\n                [\r\n                    {\r\n                        \"a\":\"TA28\"\r\n                    }\r\n                ],\r\n                \"ind1\":\" \",\r\n                \"ind2\":\" \"\r\n            }\r\n        },\r\n        {\r\n            \"991\":\r\n            {\r\n                \"subfields\":\r\n                [\r\n                    {\r\n                        \"b\":\"c-RecSound\"\r\n                    },\r\n                    {\r\n                        \"h\":\"Columbia CS 8786\"\r\n                    },\r\n                    {\r\n                        \"w\":\"MUSIC\"\r\n                    }\r\n                ],\r\n                \"ind1\":\" \",\r\n                \"ind2\":\" \"\r\n            }\r\n        }\r\n    ]\r\n}<\/pre>\n<p>The key words &#8220;MUST&#8221;, &#8220;MUST NOT&#8221;, &#8220;REQUIRED&#8221;, &#8220;SHALL&#8221;, &#8220;SHALL NOT&#8221;, &#8220;SHOULD&#8221;, &#8220;SHOULD NOT&#8221;, &#8220;RECOMMENDED&#8221;, &#8220;MAY&#8221;, and &#8220;OPTIONAL&#8221; in this document are to be interpreted as described in <a href=\"http:\/\/tools.ietf.org\/html\/rfc2119\">IETF RFC 2119<\/a>.<\/p>\n<p>MARC-in-JSON records MUST conform to the following <a href=\"http:\/\/json-schema.org\/\">JSON schema<\/a>:<\/p>\n<pre>{\r\n    \"description\":\"A MARC Record\",\r\n    \"type\": \"object\",\r\n    \"properties\": {\r\n        \"leader\": {\r\n            \"type\": \"string\",\r\n            \"minLength\": 24,\r\n            \"maxLength\": 24\r\n        },\r\n        \"fields\": {\r\n            \"type\": \"array\",\r\n            \"items\": {\r\n                \"type\":[\r\n                    {\r\n                        \"type\": \"object\",\r\n                        \"description\":\"A MARC Control Field\",\r\n                        \"additionalProperties\":{\r\n                            \"type\":\"string\"\r\n                        }\r\n                    },\r\n                    {\r\n                        \"type\": \"object\",\r\n                        \"additionalProperties\":{\r\n                            \"type\":\"object\",\r\n                            \"description\":\"A MARC Variable Field\",\r\n                            \"properties\":{\r\n                                \"ind1\":{\r\n                                    \"type\":\"string\",\r\n                                    \"minLength\":1,\r\n                                    \"maxLength\":1\r\n                                },\r\n                                \"ind2\":{\r\n                                    \"type\":\"string\",\r\n                                    \"minLength\":1,\r\n                                    \"maxLength\":1\r\n                                },\r\n                                \"subfields\":{\r\n                                    \"type\":\"array\",\r\n                                    \"items\":{\r\n                                        \"type\":\"object\",\r\n                                        \"description\":\"A MARC Subfield\",\r\n                                        \"additionalProperties\":{\r\n                                            \"type\":\"string\"\r\n                                        }\r\n                                    }\r\n                                }\r\n                            }\r\n                        }\r\n                    }\r\n                    ]\r\n                },\r\n            \"additionalProperties\": false\r\n        }\r\n    },\r\n    \"additionalProperties\": false\r\n}<\/pre>\n<p><a href=\"\/files\/marc-schema.json\">Download this schema.<\/a><\/p>\n<p>MARC-in-JSON consists of four (4) object types:<\/p>\n<dl>\n<dt><strong>Record objects<\/strong><\/dt>\n<dd>The base representation of the MARC record.  It MUST be a JSON object with two properties:<\/p>\n<ul>\n<li><em>leader<\/em>, which MUST be a string, exactly 24 characters in length.<\/li>\n<li><em>fields<\/em>, an array which MUST only contain control field and variable field objects.<\/li>\n<\/ul>\n<p>Record objects MAY be contained in a JSON array.<\/p>\n<\/dd>\n<dt><strong>Control field objects<\/strong><\/dt>\n<dd>MARC control fields MUST be represented as a JSON object with a single key\/value pair.  The key MUST be a string conforming to a valid MARC field tag value (generally three alphanumeric characters).  The value of the object MUST be a string.<\/dd>\n<dt><strong>Variable field objects<\/strong> <\/dt>\n<dt> <\/dt>\n<dd>Variable fields MUST be represented as JSON objects with a single key\/value pair.  The key MUST be a string conforming to a valid MARC field tag value (generally three alphanumeric characters).  The value of the object MUST be a JSON object with three properties:<\/p>\n<ul>\n<li><em>ind1<\/em>: a one (1) character string representing the 1st MARC field indicator<\/li>\n<li><em>ind2<\/em>: a one (1) character string representing the 2nd MARC field indicator<\/li>\n<li><em>subfields<\/em>: an array containing at least one subfield object<\/li>\n<\/ul>\n<\/dd>\n<dt><strong>Subfield objects<\/strong><\/dt>\n<dd>MARC subfields MUST be represented as JSON objects with a single key\/value pair.  The key MUST be a string conforming to a valid MARC subfield code value (generally a single alphanumeric character).  The value MUST be a string representing the value of the subfield.  A subfield object MUST only appear in a variable field object <em>subfields<\/em> array.<\/dd>\n<\/dl>\n<p>The content of a MARC-in-JSON object MUST be UTF-8 encoded or UTF-8 escaped according to the JSON standard (<a href=\"http:\/\/www.ietf.org\/rfc\/rfc4627\">RFC 4627<\/a>). \u00c2\u00a0MARC-8, UTF-16 or UTF-32 SHALL NOT be permitted under MARC-in-JSON.<\/p>\n<p>There are currently two implementations conforming to this specification for serialization:<\/p>\n<ul>\n<li>PHP\/Pear <a href=\"http:\/\/pear.php.net\/package\/File_MARC\" target=\"_blank\">File_MARC<\/a> (version &gt;= 0.6.1)<\/li>\n<li><a href=\"http:\/\/gist.github.com\/511792\" target=\"_blank\">Patch<\/a> for <a href=\"http:\/\/marc.rubyforge.org\/\" target=\"_blank\">Ruby MARC<\/a>.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Note: to see the backstory and justification of this proposal, please see the preceding post. MARC-in-JSON is a proposed JSON schema for representing MARC records as JSON. It is the outgrowth of working with MARC data in MongoDB and is intended to be both a faithful representation of MARC as well as a logical and [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[71,74],"tags":[],"class_list":["post-411","post","type-post","status-publish","format-standard","hentry","category-marc","category-marc-in-json"],"_links":{"self":[{"href":"https:\/\/rossfsinger.me\/blog\/wp-json\/wp\/v2\/posts\/411","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rossfsinger.me\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rossfsinger.me\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rossfsinger.me\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rossfsinger.me\/blog\/wp-json\/wp\/v2\/comments?post=411"}],"version-history":[{"count":10,"href":"https:\/\/rossfsinger.me\/blog\/wp-json\/wp\/v2\/posts\/411\/revisions"}],"predecessor-version":[{"id":498,"href":"https:\/\/rossfsinger.me\/blog\/wp-json\/wp\/v2\/posts\/411\/revisions\/498"}],"wp:attachment":[{"href":"https:\/\/rossfsinger.me\/blog\/wp-json\/wp\/v2\/media?parent=411"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rossfsinger.me\/blog\/wp-json\/wp\/v2\/categories?post=411"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rossfsinger.me\/blog\/wp-json\/wp\/v2\/tags?post=411"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}