Parsing nested JSON data

后端 未结 5 2031
执笔经年
执笔经年 2020-12-18 05:57

This JSON output is from a MongoDB aggregate query. I essentially need to parse the nested data JSON down to the following to the \'total\' and \'_id\'

5条回答
  •  爱一瞬间的悲伤
    2020-12-18 06:10

    This should do.

    import json
    
    def parse_json(your_json):
        to_dict = json.loads(your_json)
        for item in to_dict['results']:
            print item['total']
    

提交回复
热议问题