Python/Json:Expecting property name enclosed in double quotes
Python/Json:Expecting property name enclosed in double quotes
This:
{
http://example.org/about: {
http://purl.org/dc/terms/title: [
{type: literal, value: Annas Homepage}
]
}
}
is not JSON.
This:
{
http://example.org/about: {
http://purl.org/dc/terms/title: [
{type: literal, value: Annas Homepage}
]
}
}
is JSON.
EDIT:
Some commenters suggested that the above is not enough.
JSON specification – RFC7159 states that a string begins and ends with quotation mark. That is .
Single quoute has no semantic meaning in JSON and is allowed only inside a string.
as JSON only allows enclosing strings with double quotes you can manipulate the string like this:
str = str.replace(, )
if your JSON holds escaped single-quotes () then you should use the more precise following code:
import re
p = re.compile((?<!\\))
str = p.sub(, str)
This will replace all occurrences of single quote with double quote in the JSON string str
and in the latter case will not replace escaped single-quotes.
You can also use js-beautify
which is less strict:
$ pip install jsbeautifier
$ js-beautify file.js
Python/Json:Expecting property name enclosed in double quotes
In my case, double quotes was not a problem.
Last comma gave me same error message.
{a:{b:c,}}
^
To remove this comma, I wrote some simple code.
import json
with open(a.json,r) as f:
s = f.read()
s = s.replace(t,)
s = s.replace(n,)
s = s.replace(,},})
s = s.replace(,],])
data = json.loads(s)
And this worked for me.