Skip to content

Add basic simple example of streaming a large JSON file #137

@dandv

Description

@dandv

The README for this module is a bit daunting... lots of people are looking simply to parse a large JSON file and get objects one by one:

It would be really helpful to have a simple basic canonical example of how to parse a large JSON file that consists of an arbitrary number of objects in an array. Ideally, that would be a generator pattern, so streaming can be aborted at will, and items iterated through with a for loop like with Python's ijson library:

with open('large_file.json', 'rb') as f:
    objects = ijson.items(f, 'item')
    for o in objects:
        add_object(o)

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions