import
json
from
collections
import
Mapping
import
json
def
dict_generator(indict, pre
=
None
):
pre
=
pre[:]
if
pre
else
[]
if
isinstance
(indict,
dict
):
for
key, value
in
indict.items():
if
isinstance
(value,
dict
):
if
len
(value)
=
=
0
:
yield
pre
+
[key, ‘{}']
else
:
for
d
in
dict_generator(value, pre
+
[key]):
yield
d
elif
isinstance
(value,
list
):
if
len
(value)
=
=
0
:
yield
pre
+
[key, ‘[]']
else
:
for
v
in
value:
for
d
in
dict_generator(v, pre
+
[key]):
yield
d
elif
isinstance
(value,
tuple
):
if
len
(value)
=
=
0
:
yield
pre
+
[key, ‘()']
else
:
for
v
in
value:
for
d
in
dict_generator(v, pre
+
[key]):
yield
d
else
:
yield
pre
+
[key, value]
else
:
yield
indict
def
recursive_findall(obj, key, paths
=
None
):
ret
=
[]
if
not
paths:
paths
=
[]
if
isinstance
(obj, Mapping):
for
k, v
in
obj.iteritems():
found_items
=
recursive_findall(v, key, paths
=
(paths
+
[(‘k', k)]))
ret
+
=
found_items
elif
isinstance
(obj, (
list
,
tuple
)):
for
i, v
in
enumerate
(obj):
found_items
=
recursive_findall(v, key, paths
=
(paths
+
[(‘i', i)]))
ret
+
=
found_items
else
:
if
key(obj):
ret.append((paths, obj))
return
ret
ret_dict
=
{
“data”:[
{
“email”:"",
“repoCommits”:[
{
“branchCommitLine”:[
{
“submitLine”:
1
},
{
“submitLine”:
1
}]},
{
“branchCommitLine”: [
{
“submitLine”:
1
},
{
“submitLine”:
1
}]}]