0

I am new to python and I am pretty sure that I am doing something very stupid..

I have a string:

s = '{"l":1,"oE":{"n":"name","rN":["1","2","3","3","5","6","7","8","9","10"],"dir":"out","ed":["1","1","1","1","1","1","1","1","1","1"]}'

I did json.loads(s)

But I am getting an error?

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/json/__init__.py", line 328, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 365, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 381, in raw_decode
    obj, end = self.scan_once(s, idx)
ValueError: Expecting , delimiter: line 1 column 72 (char 72)
1
  • 1
    the last element in rN is missing a quote, and oE doesn't have a closing bracket Commented Feb 20, 2013 at 22:23

2 Answers 2

2

You're missing a quotation mark in your code. Also a closing brace. Instead of:

s = '{"l":1,"oE":{"n":"name","rN":["1","2","3","3","5","6","7","8","9","10],"dir":"out","ed":["1","1","1","1","1","1","1","1","1","1"]}'

use

s = '{"l":1,"oE":{"n":"name","rN":["1","2","3","3","5","6","7","8","9","10"],"dir":"out","ed":["1","1","1","1","1","1","1","1","1","1"]}}'

You can figure this out from your stack trace:

ValueError: Expecting , delimiter: line 1 column 72 (char 72)

If you look at the 72nd character in that line, you'll see that's where the error occurs.

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

2 Comments

You're also missing a closing brace (}) somewhere. I'm not sure exactly where you want it, but I stuck one in a place where it should work.
@user2052251 remmeber the } at the very end.
0

"10] seems to be missing a ". Try "10"] instead.

1 Comment

You are missing a } somewhere, as @raser points out in a comment. It should go at the end of "oE" value, wherever that might be.

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.