Skip to content

Instantly share code, notes, and snippets.

@gillesruppert
Created November 8, 2012 15:59
Show Gist options
  • Save gillesruppert/4039709 to your computer and use it in GitHub Desktop.
Save gillesruppert/4039709 to your computer and use it in GitHub Desktop.
Getting different keys at different paths with 1 JSONStream.parse
// given the data structure below, we want to get:
// rows.id and rows.doc._rev.
// JSONStream.parse('rows', true, /id|doc/, /(rev)?/) // doesn't work
{"total_rows":129,"offset":0,"rows":[
{ "id":"change1_0.6995461115147918"
, "key":"change1_0.6995461115147918"
, "value":{"rev":"1-e240bae28c7bb3667f02760f6398d508"}
, "doc":{
"_id": "change1_0.6995461115147918"
, "_rev": "1-e240bae28c7bb3667f02760f6398d508","hello":1}
},
{ "id":"change2_0.6995461115147918"
, "key":"change2_0.6995461115147918"
, "value":{"rev":"1-13677d36b98c0c075145bb8975105153"}
, "doc":{
"_id":"change2_0.6995461115147918"
, "_rev":"1-13677d36b98c0c075145bb8975105153"
, "hello":2
}
},
]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment