Imagine the following in python (using 2.7):
myString = '{ key: "value" }'
"value" could be a simple string, a list, a boolean or another dictionary, each of which really is in double quotes
If I try to convert this into a python dictionary or json, I fail because the key, in the original string is not quoted.
For example:
- ast.literal_eval(myString) results in: IndentationError: unexpected indent or ValueError: malformed string (depending on the complexity of myString)
- eval(myString) results in: NameError: name 'AbsolutePath' is not defined
- json.loads(myString) results in: ValueError: Expecting property name enclosed in double quotes ...
Effectively, I am getting this string from a var declaration in javascript that is being scraped from the page. myString could be storing a dictionary with 50 to 100 entries.
I don't believe this is the same as asked elsewhere since the key is unquoted and the value is.