Skip to content

Dicts with non-string keys get serialized wrong #6

Description

@qiemem

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.

Activity

  1. qiemem commented on Oct 24, 2017

    @qiemem
    OwnerAuthor

    A current workaround is to just do:

     show py:runresult "{(1,2): 3}.items()"
    
  2. qiemem commented on Nov 15, 2017

    @qiemem
    OwnerAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions