I have a large json-file (too large to fit in memory) with the following structure:
{
"commonVal": "foo",
"entries": [
{ "bar": "baz1" },
{ "bar": "baz2" },
...,
]
}
I would like to process this json file as objects like this:
commonVal: foo, bar: baz1
commonVal: foo, bar: baz2
...
I.e.
- Read
commonVal
(outside of the list) and store that in a variable, - Iterate over
entries
one by one
To my help I have the ijson
library.
I can perform step 1 using kvitems
, and step 2 using items
, but I can't figure out how to "mix" the two. (I would very much like to avoid dropping to the events-api because the entries in the list are more complex than in the example.)