Alternate way to read a file as json using python -
i have file contains information similar example shown below. know if there way read file using python , use json. aware of how open , process text there way?
example:
key={{name='foo', etc..},{},{},{}}
if want content treated json need have valid json syntax:
{"key":[{"name": "foo"},{},{},{}]}
then can use json library convert dictionary:
>>> import json >>> json.loads('{"key":[{"name": "foo"},{},{},{}]}') {u'key': [{u'name': u'foo'}, {}, {}, {}]}
additionally, if file content cannot changed correct json syntax, need develop parser specific case.
Comments
Post a Comment