from ast import literal_eval
import re
def str_diff_parse(str_diff):
return [tuple(literal_eval(y) for y in re.findall(r"\[('?\w+'?)\]", x)) for x in str_diff]
added = {'root[2]': {3: {'age': 60, 'name': 'foobar'}}}
updated = {"root[1][2]['age']": {'new_value': 90, 'old_value': 40}}
list_indexes_added = str_diff_parse(added)
list_indexes_updated = str_diff_parse(updated)
print(list_indexes_added)
print(list_indexes_updated)
ZnJvbSBhc3QgaW1wb3J0IGxpdGVyYWxfZXZhbAppbXBvcnQgcmUKCmRlZiBzdHJfZGlmZl9wYXJzZShzdHJfZGlmZik6CiAgICByZXR1cm4gW3R1cGxlKGxpdGVyYWxfZXZhbCh5KSBmb3IgeSBpbiByZS5maW5kYWxsKHIiXFsoJz9cdysnPylcXSIsIHgpKSBmb3IgeCBpbiBzdHJfZGlmZl0KCgphZGRlZCA9IHsncm9vdFsyXSc6IHszOiB7J2FnZSc6IDYwLCAnbmFtZSc6ICdmb29iYXInfX19CnVwZGF0ZWQgPSB7InJvb3RbMV1bMl1bJ2FnZSddIjogeyduZXdfdmFsdWUnOiA5MCwgJ29sZF92YWx1ZSc6IDQwfX0KCmxpc3RfaW5kZXhlc19hZGRlZCA9IHN0cl9kaWZmX3BhcnNlKGFkZGVkKQpsaXN0X2luZGV4ZXNfdXBkYXRlZCA9IHN0cl9kaWZmX3BhcnNlKHVwZGF0ZWQpCgpwcmludChsaXN0X2luZGV4ZXNfYWRkZWQpCnByaW50KGxpc3RfaW5kZXhlc191cGRhdGVkKQ==