Dicts with non-string keys get serialized wrong
qiemem opened this issue · 2 comments
qiemem commented
Some examples:
observer> show py:runresult "{1: 2}"
observer: [["1" 2]]
observer> show py:runresult "{(1,2): 3}"
Extension exception: keys must be a string
While JSON is restricted to string keys, we are not. We need to hijack JSON's dict serialization to turn them into a list of pairs instead.
qiemem commented
A current workaround is to just do:
show py:runresult "{(1,2): 3}.items()"
qiemem commented
This is because keys are always strings in JSON. So I think the only way to fix this is to either:
- Switch away from JSON
- Convert dicts to lists of pairs before serialization