Closed mnoop closed 3 years ago
Hello,
Yes, this is a known problem. We got a workaround for the JSON.GET command, but not implemented for others. I guess we should rework the decoding implementation to take care of this specific instance.
There is however a quick fix for your problem: a custom JSON decoder. You can implement it by passing it to your ReJSON client instance.
import json
from rejson import Client
class CustomDecoder(json.JSONDecoder):
def decode(self, s: str, *args, **kwargs):
try:
return json.JSONDecoder.decode(self, s, *args, **kwargs)
except TypeError:
if s is not None:
raise
return None
decoder = CustomDecoder()
rj = Client(host='localhost', port=6379, decode_responses=True, decoder=decoder)
This will catch all None values coming back from ReJSON and return them correctly, in any JSON.* commands.
fixed by #46
If you execute jsonget on the Client and the key does not exist, it will catch the TypeError and instead return None, as expected.
If you execute jsonget on a pipeline and the key does not exist, it will throw the TypeError that results from json decoding the None value. Because of this, I cannot get any of the other results from the other commands from the pipeline.
Python 3.6.9 rejson 0.5.4