I had some JSON data containing dot(.) in keys that are written to redis using redis-py like this:
r = redis.Redis()
r.json().set(_id, "$", {'First.Last': "John.Smith"})
It works if reading the whole JSON data like
r.json().get(_id)
but error throws if directly getting the value with a path containing the dot:
r.json().get(_id, "First\.Last")  # ResponseError
Obviously, the dot is not correctly escaped. Also tried to quote it like "'First.Last'"but doesn't work either. What's the correct way to deal with this special character in a key? The redis instance is a redis-stack-server docker container running on linux. Thank you!
RedisJSON path supports both dot and bracket notation https://redis.io/docs/stack/json/path/, so you could use this
r.json().get(_id, '["First.Last"]')
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With