summaryrefslogtreecommitdiff
path: root/redis/commands/json/helpers.py
diff options
context:
space:
mode:
authorChayim <chayim@users.noreply.github.com>2021-10-25 17:06:04 +0300
committerGitHub <noreply@github.com>2021-10-25 17:06:04 +0300
commit3946da29d7e451a20289fb6e282516fa24e402af (patch)
tree25cf4b73b4e00d66c75288790616ea882823e2b7 /redis/commands/json/helpers.py
parent0ef4c0711693b4b313ce97261214bd151d8261d5 (diff)
downloadredis-py-3946da29d7e451a20289fb6e282516fa24e402af.tar.gz
redisjson support (#1636)
Diffstat (limited to 'redis/commands/json/helpers.py')
-rw-r--r--redis/commands/json/helpers.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/redis/commands/json/helpers.py b/redis/commands/json/helpers.py
new file mode 100644
index 0000000..8fb20d9
--- /dev/null
+++ b/redis/commands/json/helpers.py
@@ -0,0 +1,25 @@
+import copy
+
+
+def bulk_of_jsons(d):
+ """Replace serialized JSON values with objects in a
+ bulk array response (list).
+ """
+
+ def _f(b):
+ for index, item in enumerate(b):
+ if item is not None:
+ b[index] = d(item)
+ return b
+
+ return _f
+
+
+def decode_dict_keys(obj):
+ """Decode the keys of the given dictionary with utf-8."""
+ newobj = copy.copy(obj)
+ for k in obj.keys():
+ if isinstance(k, bytes):
+ newobj[k.decode("utf-8")] = newobj[k]
+ newobj.pop(k)
+ return newobj