userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
object_hook.py
1
def
substitute(json_obj, hook):
2
if
hook
is
None
:
3
return
json_obj
4
if
isinstance(json_obj, dict):
5
return
hook(
6
{key: substitute(value, hook)
for
key, value
in
json_obj.items()},
7
)
8
if
isinstance(json_obj, list):
9
return
[substitute(element, hook)
for
element
in
json_obj]
10
return
json_obj
11
12
13
def
build_object_hook(object_hook):
14
if
object_hook
is
None
:
15
return
None
16
if
callable(object_hook):
17
return
object_hook
18
if
isinstance(object_hook, dict):
19
object_hook = object_hook.items()
20
21
def
hook(doc):
22
for
key, hook
in
object_hook:
23
if
key
in
doc:
24
return
hook(doc)
25
return
doc
26
27
return
hook
en
testsuite
utils
object_hook.py
Generated on
for userver by
Doxygen
1.17.0