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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -