Loading and parsing a JSON file with multiple JSON objects

前端 未结 3 1691
醉话见心
醉话见心 2020-11-22 09:40

I am trying to load and parse a JSON file in Python. But I\'m stuck trying to load the file:

import json
json_data = open(\'file\')
data = json.load(json_dat         


        
3条回答
  •  佛祖请我去吃肉
    2020-11-22 10:33

    That is ill-formatted. You have one JSON object per line, but they are not contained in a larger data structure (ie an array). You'll either need to reformat it so that it begins with [ and ends with ] with a comma at the end of each line, or parse it line by line as separate dictionaries.

提交回复
热议问题