Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dicts with non-string keys get serialized wrong #6

Open
qiemem opened this issue Oct 24, 2017 · 2 comments
Open

Dicts with non-string keys get serialized wrong #6

qiemem opened this issue Oct 24, 2017 · 2 comments
Labels

Comments

@qiemem
Copy link
Owner

qiemem commented Oct 24, 2017

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 qiemem added the bug label Oct 24, 2017
@qiemem
Copy link
Owner Author

qiemem commented Oct 24, 2017

A current workaround is to just do:

 show py:runresult "{(1,2): 3}.items()"

@qiemem
Copy link
Owner Author

qiemem commented Nov 15, 2017

This is because keys are always strings in JSON. So I think the only way to fix this is to either:

  1. Switch away from JSON
  2. Convert dicts to lists of pairs before serialization

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant