1

I am having JSON syntax issues when I am using the following code code: https://github.com/clarkbk/streeteasy-analysis

Using this JSON in buildings.json

{
  "buildings": [
    {
      "name": "Henry Hall",
      "addr": "https://streeteasy.com/nyc/property_activity/past_transactions_component/799324?all_activity=true&show_rentals=true&style=xls",
      "id": 799324,
    }
  ]
}

I am getting the following error:

2019-05-25 16:04:26,641 - INFO - Starting...
Traceback (most recent call last):
  File "run.py", line 27, in <module>
    data = json.load(f)
  File "/usr/lib/python3.6/json/__init__.py", line 299, in load
    parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
  File "/usr/lib/python3.6/json/__init__.py", line 354, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.6/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.6/json/decoder.py", line 355, in raw_decode
    obj, end = self.scan_once(s, idx)
json.decoder.JSONDecodeError: Expecting property name enclosed in double quotes: line 9 column 5 (char 220)
root@LAPTOP-4QGC19OR:/home/HN/streeteasy-analysis#

I have researched for a few hours now on how to fix this but can't come up with a fix. I am not that familiar with JSON in general but I don't know where I am not double qouting properly. Appreciate any help with this.

1
  • 1
    "id": 799324 } json isn't python, if there's a comma on last element it fails Commented May 25, 2019 at 20:12

1 Answer 1

2

The line number gives a good hint

you want:

 "id": 799324
}

(note no comma after the last element)

json isn't python ast.literal_eval, if there's a comma on last element it fails, because it expects another property as the message states (Expecting property name enclosed in double quotes explains that, although the message could be better, as this error is very common)

If you have data like this, you can use ast.literal_eval on it instead, it will work without modifications (unless there are false or null json booleans/null-pointers)

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! This worked, I also had to add a url definition in the JSON if anybody comes across this answer in the future.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.