0

i am trying to load a json file through following code

import json

with open('ass1//data//reviews_Digital_Music.json', encoding="utf8") as f:
    review = json.load(f,encoding="utf8")

Return error

C:\Users\Admin\Anaconda3\lib\json\decoder.py", line 342, in decode
raise JSONDecodeError("Extra data", s, end)
JSONDecodeError: Extra data

for more insight you can find part of my json file, the document has 10000 more such dictionary

{"reviewerID": "A2EFCYXHNK06IS","asin": "5555991584", "reviewerName": "Abigail Perkins \"Abby "Reads Too Much&#34...", "helpful": [4, 5], "reviewText": "text", "overall": 5.0, "summary": "Enya Experiments And Succeeds", "unixReviewTime": 978480000, "reviewTime": "01 3, 2001"}
{"reviewerID": "A1WR23ER5HMAA9", "asin": "5555991584", "reviewerName": "AKB", "helpful": [1, 1], "reviewText": "text", "overall": 5.0, "summary": "How to improve upon perfection.", "unixReviewTime": 953424000, "reviewTime": "03 19, 2000"}
{"reviewerID": "A2IR4Q0GPAFJKW", "asin": "5555991584", "reviewerName": "Alexander", "helpful": [0, 0], "reviewText": "text", "overall": 4.0, "summary": "Good listening.", "unixReviewTime": 1393545600, "reviewTime": "02 28, 2014"}

how can i load it as dic?

Ehsan
  • 11
  • 1
  • 7
  • 1
    ``part of my json file`` is not helpful for us to help you. Please provide a [mcve] – Mike Scotty Mar 24 '18 at 21:46
  • should i upload the json file? it is 32GB – Ehsan Mar 24 '18 at 21:58
  • 1
    No, please provide a **minimal**, complete and verifiable example. – Mike Scotty Mar 24 '18 at 22:02
  • Isn't it should be `'r'` like: `with open('ass1//data//reviews_Digital_Music.json', 'r') as f:` – jujuBee Mar 24 '18 at 22:09
  • It looks like your json file is a little wonky. What process did you go through to make it? How exactly is it structured? Check out this similar question https://stackoverflow.com/questions/21058935/python-json-loads-shows-valueerror-extra-data – kilojoules Mar 24 '18 at 22:09
  • i already have seen this question, perhaps nested dictionary inside each other was the cause of error but in my case as you see it is just dictionary with a list inside. the document has 10000 more such dictionary. also i tried with "r", there is same issue – Ehsan Mar 24 '18 at 22:46
  • @beegee: It doesn't because `'r'` is the default mode for `open()`. – martineau Mar 24 '18 at 23:24
  • 1
    Might be a duplicate of https://stackoverflow.com/questions/12451431/loading-and-parsing-a-json-file-with-multiple-json-objects-in-python – Arndt Jonasson Mar 25 '18 at 05:29
  • @ArndtJonasson Thank you, it work – Ehsan Mar 25 '18 at 11:23

0 Answers0