Non-string dictionary keys #3

Open
opened 6 years ago by novirium · 1 comments
Owner

Currently Preserve errors out when it encounters a dictionary key that's not a string. Need to see if it's viable to support other keys.

Currently Preserve errors out when it encounters a dictionary key that's not a string. Need to see if it's viable to support other keys.
novirium added the [type] Enhancement [status] Review labels 6 years ago
Poster
Owner

I think we want to maintain the current rule where output dicts always have string keys. To be able to handle other objects as keys on the Python side would require the class_key escaped dict extension we've been considering.

In that scenario, we'd create a class_key escaped dict (where rather than just a class name as the value, we create a whole new dict) beside the keys that were still strings. In the escaped dict we'd then have key pairs something like 'key_1', 'val_1', 'key_2', 'val_2', which then held the preserved content of the key and value pair from the original raw dict. We have to pull the values over into the escaped section too - as leaving them in the non-escaped section would risk a naming collision (we'd have to name them with a string key of some sort).

I think we want to maintain the current rule where output dicts always have string keys. To be able to handle other objects as keys on the Python side would require the `class_key` escaped dict extension we've been considering. In that scenario, we'd create a `class_key` escaped dict (where rather than just a class name as the value, we create a whole new dict) beside the keys that _were_ still strings. In the escaped dict we'd then have key pairs something like 'key_1', 'val_1', 'key_2', 'val_2', which then held the preserved content of the key and value pair from the original raw dict. We have to pull the values over into the escaped section too - as leaving them in the non-escaped section would risk a naming collision (we'd have to name them with a string key of some sort).
Sign in to join this conversation.
Loading…
There is no content yet.