How do I remove an extra square bracket from JSON in Python? -
i have json of following form:
{"blah": [ [ {"first": {"something":"that","something":"else","another":"thing","key":"value"}...[etc.] } ] ] }
that i'm trying parse in python. i've imported json (or simplejson, depending on version of python you're using) , goes pretty until block:
for result in page['blah']: = result['first'] a_list.append(that)
which throws error "typeerror: list indices must integers, not str".
i'm pretty sure error due pair of square-bracket makes json inside list.
my question, assuming that's case, is, how remove , still have valid json parse dictionaries?
other workarounds welcome. if need supply more info, let me know. thanks!
(added missing curly bracket , changed couple of confusing terms--i trying come generic terms on fly, sorry confusion.)
if there's 1 "extra" set of array brackets:
for result in page['blah']: = result[0]['this'] list.append(that)
Comments
Post a Comment