2

I am trying to run this simple program on python:

import json
json.loads('["foo", {"bar":["baz", null, 1.0, 2]}]')

But it is giving an error like this:

Traceback (most recent call last):
  File "jsonURL.py", line 2, in <module>
    json.loads('["foo", {"bar":["baz", null, 1.0, 2]}]')
AttributeError: 'module' object has no attribute 'loads'

I know the program is correct what am i missing here?

6
  • which version of Python? Commented Jun 29, 2012 at 8:38
  • 2
    Do you have a file called json.py in your project? Commented Jun 29, 2012 at 8:42
  • '2.7.3 (default, Apr 20 2012, 22:44:07) \n[GCC 4.6.3]' Commented Jun 29, 2012 at 9:10
  • @DanielRoseman No. is it required ? and where can I get it ? Commented Jun 29, 2012 at 9:11
  • OK now i have json.py and then also same error. Commented Jun 29, 2012 at 9:18

1 Answer 1

4

Do you have another python file called json.py in your path? Also take a look at your json modules methods with dir(json).

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

Comments

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.