Skip to content

Instantly share code, notes, and snippets.

@rsinger
Created August 6, 2010 18:33
Show Gist options
  • Save rsinger/511752 to your computer and use it in GitHub Desktop.
Save rsinger/511752 to your computer and use it in GitHub Desktop.
{
"_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"
}
]
}
}
]
}
@rsinger
Copy link
Author

rsinger commented Aug 14, 2010

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?

@dbs
Copy link

dbs commented Aug 14, 2010

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.

@rsinger
Copy link
Author

rsinger commented Aug 14, 2010

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment