Hello, i need help with the code. I need read code of JSON, but I have a problem

with open(‘new_york_times.json’,mode=“+r”,encoding=“UTF-8”) as contenido:
set_datos = json.load(contenido)
df = pd.DataFrame.from_dict(set_datos)

But i get this error:
Traceback (most recent call last):
File “c:\Users\aquiroz\OneDrive - Unified Networks\Documentos\adi VS\jsob.py”, line 14, in
set_datos = json.load(contenido)
^^^^^^^^^^^^^^^^^^^^
File “C:\Users\aquiroz\AppData\Local\Programs\Python\Python312\Lib\json_init_.py”, line 293, in load
return loads(fp.read(),
^^^^^^^^^^^^^^^^
File “C:\Users\aquiroz\AppData\Local\Programs\Python\Python312\Lib\json_init_.py”, line 346, in loads
return _default_decoder.decode(s)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File “C:\Users\aquiroz\AppData\Local\Programs\Python\Python312\Lib\json\decoder.py”, line 340, in decode
raise JSONDecodeError(“Extra data”, s, end)
json.decoder.JSONDecodeError: Extra data: line 2 column 1 (char 564)

Hi,

Before posting, please read how to post code: About the Python Help category
Thank you.

You do not have a JSON input file. You have JSONL, which is a little different. It is like a separate JSON document, on each line of the file. This is a very common format.

Pandas has its own support for JSON files and it also handles JSONL:

df = pd.read_json('new_york_times.json', lines=True)

lines=True tells it to read JSONL instead of normal JSON.

Thanks for you help karl