0

i have an string for example

var = "{"name":"angelo","apellido":"enriquez"}"

but when doing the following function I get an error

data = json.loads(var)

Error : No JSON object could be decoded Any help?

The6thSense
8,3559 gold badges38 silver badges67 bronze badges
asked Jun 19, 2015 at 5:14
1
  • please select an answer if this helped Commented Jun 19, 2015 at 6:31

2 Answers 2

1

Replace your var with :

var = '{"name":"angelo","apellido":"enriquez"}'

i.e put the content inside {} within single quotes (') instead of double .

Hope that helps .

answered Jun 19, 2015 at 5:20
Sign up to request clarification or add additional context in comments.

1 Comment

YEAH , IT WORKS THNKS
0

First of all you are not writing good json in javascript, replace inner " double quotes with single ' quotes.

var MyJSVar = {'hello':'bra'}

If string

var MyJSVar = "{'hello':'bra'}"
answered Jun 19, 2015 at 5:16

2 Comments

is beacause i'm reading from a file .. and returns me a str i guess that it is between " ...."
i use Readlines and this iterate into a loop

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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.