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
-
please select an answer if this helpedDr.Knowitall– Dr.Knowitall2015年06月19日 06:31:12 +00:00Commented Jun 19, 2015 at 6:31
2 Answers 2
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
Ram K
1,7952 gold badges16 silver badges25 bronze badges
Sign up to request clarification or add additional context in comments.
1 Comment
Angelo Enriquez
YEAH , IT WORKS THNKS
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
Dr.Knowitall
10.5k25 gold badges90 silver badges139 bronze badges
2 Comments
Angelo Enriquez
is beacause i'm reading from a file .. and returns me a str i guess that it is between " ...."
Angelo Enriquez
i use Readlines and this iterate into a loop
lang-py