Iteratively parse JSON file

前端 未结 3 1908

I have 1000+ JSON files that look like

{
    \"name\": \"Some name\",
    \"part_num\": \"123456\",

    \"other_config\":         


        
3条回答
  •  南方客
    南方客 (楼主)
    2021-01-24 04:31

    There is ijson which performs performs iterative json parsing in a pythonc way.

    I guess that solution to your problem would be:

    import ijson
    
    f = open('...')
    objects = ijson.items(f, 'other_config.item')
    for part in objects:
        do_something_with(part)
    

    Dislaimer I did not use that library.

提交回复
热议问题