public
Created

  • Download Gist
gistfile1.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182
{
"_id" : ObjectId("4c5c5542124ba05b7c000001"),
"leader" : "00597cz a2200217n 4500",
"fields" : [
{
"001" : "6"
},
{
"005" : "19840322000000.0"
},
{
"008" : "821220n| acaaaaaa |a aaa "
},
{
"010" : {
"ind1" : " ",
"ind2" : " ",
"subfields" : [
{
"a" : "n 42000048 "
}
]
}
},
{
"035" : {
"ind1" : " ",
"ind2" : " ",
"subfields" : [
{
"a" : "(DLC)n 42000048"
}
]
}
},
{
"040" : {
"ind1" : " ",
"ind2" : " ",
"subfields" : [
{
"a" : "DLC"
},
{
"c" : "DLC"
}
]
}
},
{
"100" : {
"ind1" : "1",
"ind2" : "0",
"subfields" : [
{
"a" : "Asaka, Toshiki,"
},
{
"d" : "1934-"
},
{
"t" : "Hokuriku no kodai to chūsei"
}
]
}
},
{
"430" : {
"ind1" : " ",
"ind2" : "0",
"subfields" : [
{
"a" : "Hokuriku no kodai to chūsei"
}
]
}
},
{
"641" : {
"ind1" : " ",
"ind2" : " ",
"subfields" : [
{
"a" : "Projected in 3 v."
}
]
}
},
{
"642" : {
"ind1" : " ",
"ind2" : " ",
"subfields" : [
{
"a" : "2"
},
{
"5" : "DLC"
}
]
}
},
{
"643" : {
"ind1" : " ",
"ind2" : " ",
"subfields" : [
{
"a" : "Tokyo"
},
{
"b" : "Hōsei Daigaku Shuppankyoku"
}
]
}
},
{
"644" : {
"ind1" : " ",
"ind2" : " ",
"subfields" : [
{
"a" : "f"
},
{
"5" : "DLC"
}
]
}
},
{
"645" : {
"ind1" : " ",
"ind2" : " ",
"subfields" : [
{
"a" : "t"
},
{
"5" : "DLC"
}
]
}
},
{
"646" : {
"ind1" : " ",
"ind2" : " ",
"subfields" : [
{
"a" : "s"
},
{
"5" : "DLC"
}
]
}
},
{
"670" : {
"ind1" : " ",
"ind2" : " ",
"subfields" : [
{
"a" : "Asaka, Toshiki. Jishō Juei no nairanron josetsu. 1981."
}
]
}
},
{
"953" : {
"ind1" : " ",
"ind2" : " ",
"subfields" : [
{
"a" : "xx00"
}
]
}
}
]
}

File_MARC JSON output:

{
"leader" : "01850 2200517 4500",
"fields" : [
{
"001" : "0000000044"
},
{
"003" : "EMILDA"
},
{
"008" : "980120s1998 fi j 000 0 swe"
},
{
"020" : {
"subfields" : [
{
"a" : "9515008808"
},
{
"c" : "FIM 72:00"
}
],
"ind1" : " ",
"ind2" : " "
}
},
{
"035" : {
"subfields" : [
{
"9" : "9515008808"
}
],
"ind1" : " ",
"ind2" : " "
}
},
{
"040" : {
"subfields" : [
{
"a" : "NB"
}
],
"ind1" : " ",
"ind2" : " "
}
},
{
"042" : {
"subfields" : [
{
"9" : "NB"
},
{
"9" : "SEE"
}
],
"ind1" : " ",
"ind2" : " "
}
},
{
"084" : {
"subfields" : [
{
"a" : "Hcd,u"
},
{
"2" : "kssb/6"
}
],
"ind1" : " ",
"ind2" : " "
}
},
{
"084" : {
"subfields" : [
{
"5" : "NB"
},
{
"a" : "uHc"
},
{
"2" : "kssb"
}
],
"ind1" : " ",
"ind2" : " "
}
},
{
"084" : {
"subfields" : [
{
"5" : "SEE"
},
{
"a" : "Hcf"
},
{
"2" : "kssb/6"
}
],
"ind1" : " ",
"ind2" : " "
}
},
{
"084" : {
"subfields" : [
{
"5" : "Q"
},
{
"a" : "Hcd,uf"
},
{
"2" : "kssb/6"
}
],
"ind1" : " ",
"ind2" : " "
}
},
{
"100" : {
"subfields" : [
{
"a" : "Jansson, Tove,"
},
{
"d" : "1914-2001"
}
],
"ind1" : "1",
"ind2" : "1"
}
},
{
"245" : {
"subfields" : [
{
"a" : "Det osynliga barnet och andra berättelser /"
},
{
"c" : "Tove Jansson"
}
],
"ind1" : "0",
"ind2" : "0"
}
},
{
"250" : {
"subfields" : [
{
"a" : "7. uppl."
}
],
"ind1" : " ",
"ind2" : " "
}
},
{
"260" : {
"subfields" : [
{
"a" : "Helsingfors :"
},
{
"b" : "Schildt,"
},
{
"c" : "1998 ;"
},
{
"e" : "(Falun :"
},
{
"f" : "Scandbook)"
}
],
"ind1" : " ",
"ind2" : " "
}
},
{
"300" : {
"subfields" : [
{
"a" : "166, [4] s. :"
},
{
"b" : "ill. ;"
},
{
"c" : "21 cm"
}
],
"ind1" : " ",
"ind2" : " "
}
},
{
"440" : {
"subfields" : [
{
"a" : "Mumin-biblioteket,"
},
{
"x" : "99-0698931-9"
}
],
"ind1" : " ",
"ind2" : " "
}
},
{
"500" : {
"subfields" : [
{
"a" : "Originaluppl. 1962"
}
],
"ind1" : " ",
"ind2" : " "
}
},
{
"599" : {
"subfields" : [
{
"a" : "Li: S"
}
],
"ind1" : " ",
"ind2" : " "
}
},
{
"740" : {
"subfields" : [
{
"a" : "Det osynliga barnet"
}
],
"ind1" : "4",
"ind2" : "4"
}
},
{
"775" : {
"subfields" : [
{
"z" : "951-50-0385-7"
},
{
"w" : "9515003857"
},
{
"9" : "07"
}
],
"ind1" : "1",
"ind2" : "1"
}
},
{
"841" : {
"subfields" : [
{
"5" : "Li"
},
{
"a" : "xa"
},
{
"b" : "0201080u 0 4000uu |000000"
},
{
"e" : "1"
}
],
"ind1" : " ",
"ind2" : " "
}
},
{
"841" : {
"subfields" : [
{
"5" : "SEE"
},
{
"a" : "xa"
},
{
"b" : "0201080u 0 4000uu |000000"
},
{
"e" : "1"
}
],
"ind1" : " ",
"ind2" : " "
}
},
{
"841" : {
"subfields" : [
{
"5" : "L"
},
{
"a" : "xa"
},
{
"b" : "0201080u 0 4000uu |000000"
},
{
"e" : "1"
}
],
"ind1" : " ",
"ind2" : " "
}
},
{
"841" : {
"subfields" : [
{
"5" : "NB"
},
{
"a" : "xa"
},
{
"b" : "0201080u 0 4000uu |000000"
},
{
"e" : "1"
}
],
"ind1" : " ",
"ind2" : " "
}
},
{
"841" : {
"subfields" : [
{
"5" : "Q"
},
{
"a" : "xa"
},
{
"b" : "0201080u 0 4000uu |000000"
},
{
"e" : "1"
}
],
"ind1" : " ",
"ind2" : " "
}
},
{
"841" : {
"subfields" : [
{
"5" : "S"
},
{
"a" : "xa"
},
{
"b" : "0201080u 0 4000uu |000000"
},
{
"e" : "1"
}
],
"ind1" : " ",
"ind2" : " "
}
},
{
"852" : {
"subfields" : [
{
"5" : "NB"
},
{
"b" : "NB"
},
{
"c" : "NB98:12"
},
{
"h" : "plikt"
},
{
"j" : "R, 980520"
}
],
"ind1" : " ",
"ind2" : " "
}
},
{
"852" : {
"subfields" : [
{
"5" : "Li"
},
{
"b" : "Li"
},
{
"c" : "CNB"
},
{
"h" : "h,u"
}
],
"ind1" : " ",
"ind2" : " "
}
},
{
"852" : {
"subfields" : [
{
"5" : "SEE"
},
{
"b" : "SEE"
}
],
"ind1" : " ",
"ind2" : " "
}
},
{
"852" : {
"subfields" : [
{
"5" : "Q"
},
{
"b" : "Q"
},
{
"j" : "98947"
}
],
"ind1" : " ",
"ind2" : " "
}
},
{
"852" : {
"subfields" : [
{
"5" : "L"
},
{
"b" : "L"
},
{
"c" : "0100"
},
{
"h" : "98/"
},
{
"j" : "3043 H"
}
],
"ind1" : " ",
"ind2" : " "
}
},
{
"852" : {
"subfields" : [
{
"5" : "S"
},
{
"b" : "S"
},
{
"h" : "Sv97"
},
{
"j" : "7235"
}
],
"ind1" : " ",
"ind2" : " "
}
},
{
"900" : {
"subfields" : [
{
"a" : "Yanson, Tobe,"
},
{
"d" : "1914-2001"
},
{
"u" : "Jansson, Tove,"
},
{
"d" : "1914-2001"
}
],
"ind1" : "1",
"ind2" : "1"
}
},
{
"900" : {
"subfields" : [
{
"a" : "Janssonová, Tove,"
},
{
"d" : "1914-2001"
},
{
"u" : "Jansson, Tove,"
},
{
"d" : "1914-2001"
}
],
"ind1" : "1",
"ind2" : "1"
}
},
{
"900" : {
"subfields" : [
{
"a" : "Jansone, Tuve,"
},
{
"d" : "1914-2001"
},
{
"u" : "Jansson, Tove,"
},
{
"d" : "1914-2001"
}
],
"ind1" : "1",
"ind2" : "1"
}
},
{
"900" : {
"subfields" : [
{
"a" : "Janson, Tuve,"
},
{
"d" : "1914-2001"
},
{
"u" : "Jansson, Tove,"
},
{
"d" : "1914-2001"
}
],
"ind1" : "1",
"ind2" : "1"
}
},
{
"900" : {
"subfields" : [
{
"a" : "Jansson, Tuve,"
},
{
"d" : "1914-2001"
},
{
"u" : "Jansson, Tove,"
},
{
"d" : "1914-2001"
}
],
"ind1" : "1",
"ind2" : "1"
}
},
{
"900" : {
"subfields" : [
{
"a" : "Janssonova, Tove,"
},
{
"d" : "1914-2001"
},
{
"u" : "Jansson, Tove,"
},
{
"d" : "1914-2001"
}
],
"ind1" : "1",
"ind2" : "1"
}
},
{
"976" : {
"subfields" : [
{
"a" : "Hcd,u"
},
{
"b" : "Skönlitteratur"
}
],
"ind1" : " ",
"ind2" : " "
}
},
{
"005" : "20050204111518.0"
}
]
}

Awesome. So the question at this point is, is this useful? I mean, it works pretty well for MongoDB, but that's because it has sort of an XPath-y like syntax to query, like "fields.245.a"

However, this is more like:
fields[5]['245'][0]['a'][0]

which is WAY awkward. So my question is, if you need a DSL to do anything with it, is it worth it at all?

Even if you went with a hash instead of an array of fields, throwing away round-tripping, you would still run into a problem with multiple fields of the same tag and multiple subfields with the same code:

fields.650[0]["a"][0]

Still gross.

But I think your original round-trippable JSON format is useful if you want to use a JSON->native mappings and use native iterators, etc, rather than having to go through the intermediary pain and additional sluggishness of a MARC or XML parsing library.

Agreed. MARC's going to suck any way you cut it.

This:
http://goessner.net/articles/JsonPath/
would make this a no-brainer, really.

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.