summaryrefslogtreecommitdiff
path: root/redis/commands/json/path.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/path.py
parent0ef4c0711693b4b313ce97261214bd151d8261d5 (diff)
downloadredis-py-3946da29d7e451a20289fb6e282516fa24e402af.tar.gz
redisjson support (#1636)
Diffstat (limited to 'redis/commands/json/path.py')
-rw-r--r--redis/commands/json/path.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/redis/commands/json/path.py b/redis/commands/json/path.py
new file mode 100644
index 0000000..dff8648
--- /dev/null
+++ b/redis/commands/json/path.py
@@ -0,0 +1,21 @@
+def str_path(p):
+ """Return the string representation of a path if it is of class Path."""
+ if isinstance(p, Path):
+ return p.strPath
+ else:
+ return p
+
+
+class Path(object):
+ """This class represents a path in a JSON value."""
+
+ strPath = ""
+
+ @staticmethod
+ def rootPath():
+ """Return the root path's string representation."""
+ return "."
+
+ def __init__(self, path):
+ """Make a new path based on the string representation in `path`."""
+ self.strPath = path