0

I am just learning python and can not solve one issue. The input json text like:

[1123771,10,7699,4357,'UMF Selfoss','Haukar Hafnarfjordur','2015,5,25,19,15,00','2015,5,25,20,16,37',-1,0,1,0,1,0,0,2,2,'8','7',,'True',0.25,'',25,'',2.75]

Then I trying to use python json module to parse it i get an error. Here is the code:

js = json.loads("[1123771,10,7699,4357,'UMF Selfoss','Haukar Hafnarfjordur','2015,5,25,19,15,00','2015,5,25,20,16,37',-1,0,1,0,1,0,0,2,2,'8','7',,'True',0.25,'',25,'',2.75]")

The error is:

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Python27\lib\json\__init__.py", line 338, in loads
    return _default_decoder.decode(s)
  File "C:\Python27\lib\json\decoder.py", line 366, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Python27\lib\json\decoder.py", line 384, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

This json text successfuly parsed by another frameworks like json.net (C#). So the question is what I doing wrong?

2 Answers 2

4

Your json needs to be valid in order to be able to parse it:

Use this tool :

http://jsonlint.com/

JSON only works with double quotes.

Also two consecutive commas would make your JSON invalid

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

Comments

0

It's wrong JSON format. Check it by using some online services.

2 Comments

I don't see any validation option at this site. I tried jsonlint.com And actually that's true. meda is right. JSON needs double quotes.
sorry. you are right. So I where the simple way to convert this string to python list?

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.