0

Try to solve example given in this link But It give error. Parsing values from a JSON file?

a.json

{
    "maps": [
        {
            "id": "blabla",
            "iscategorical": "0"
        },
        {
            "id": "blabla",
            "iscategorical": "0"
        }
    ],
    "masks": {
        "id": "valore"
    },
    "om_points": "value",
    "parameters": {
        "id": "valore"
    }
}

Python file

import json
from pprint import pprint

data = json.load(open('a.json'))

pprint(data)

ERRORS

  data = json.load(open('a.json'))
  File "C:\Users\Almaas\AppData\Local\Programs\Python\Python36-32\lib\json\__init__.py", line 299, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "C:\Users\Almaas\AppData\Local\Programs\Python\Python36-32\lib\json\__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "C:\Users\Almaas\AppData\Local\Programs\Python\Python36-32\lib\json\decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\Almaas\AppData\Local\Programs\Python\Python36-32\lib\json\decoder.py", line 355, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting ',' delimiter: line 2 column 1 (char 740)
Artier
  • 1,648
  • 2
  • 8
  • 22
  • 2
    For me it runs correctly, you could share the .json in a zip and share the link, I think you have not placed the proper .json that generates the error. – eyllanesc Dec 17 '17 at 17:06
  • It given file type json – Artier Dec 17 '17 at 17:08
  • This Error remove when I read another text file in same python file with .read() command. then this (json file)error is automatically remove. But When I create new python file than again this error come. But after reading other text file with .read() command this error is going and I am able to read json fail. mean without reading text file I am not able to read json file. Fail to understand issue – Artier Dec 17 '17 at 17:49

0 Answers0