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

timeout - Handshake_timeout on RabbitMQ using python and pika from remote vm -

gcc - MinGW's ld cannot perform PE operations on non PE output file -

c# - Search and Add Comment with OpenXML for Word -