You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I may have misunderstood the library, but is there any way to loop over structures without any prefixes? I've been working in a memory-constrained environment where I wish to replace something like the following
data = json.load(srcfile)
for value in data.values():
do_something(value)
ie. converting some JSON into CSV.
To do this with IJSON I've had to drop down to the basic_parser() where I manually handle start_array and end_array, concatenate values and ignore other events. But it feels like there should be another way.
The text was updated successfully, but these errors were encountered:
@Themanwithoutaplan based on what you describe and on your code (you use data.values() so I'm assuming your JSON document has a dictionary at the top level) I think you want to use the kvitems function with an empty prefix (i.e., ''), and look at the resulting values.
If instead your JSON document has an array at the top level you'll want to use the items function with an item prefix.
Thanks very much! I thought that might be the case because the docs do mention the empty string. I might make a PR to the docs to make this option a bit clearer.
I may have misunderstood the library, but is there any way to loop over structures without any prefixes? I've been working in a memory-constrained environment where I wish to replace something like the following
ie. converting some JSON into CSV.
To do this with IJSON I've had to drop down to the
basic_parser()
where I manually handlestart_array
andend_array
, concatenate values and ignore other events. But it feels like there should be another way.The text was updated successfully, but these errors were encountered: