consulate icon indicating copy to clipboard operation
consulate copied to clipboard

json encode problem

Open simonzen opened this issue 3 years ago • 0 comments

First, guys, thank you for the library - it's awwesome! I use consul as a key/value storage and met the following problem. In method consul_instance.kv.items() I got an error

Traceback (most recent call last): File "/Users/sfokin/projects/eaas_libs/test.py", line 10, in print(test_inst.kv.items()) File "/usr/local/lib/python3.9/site-packages/consulate/api/kv.py", line 181, in items return [{item['Key']: item['Value']} for item in self._get_all_items()] File "/usr/local/lib/python3.9/site-packages/consulate/api/kv.py", line 181, in return [{item['Key']: item['Value']} for item in self._get_all_items()] TypeError: string indices must be integers

It seems that in base.py in Response class we don't need to encode value = json.loads(body, encoding='utf-8') (line 140) When I replaced it with this line value = json.loads(body) all worked correctly.

simonzen avatar Nov 25 '21 17:11 simonzen