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

Popular posts from this blog

java - BeanIO write annotated class to fixedlength -

Using Java 8 lambdas/transformations to combine and flatten two Maps -

How to connect android app to App engine -