You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using msgpack to serialize python data and then I want to unpack that again in my typescript code. In msgpackr 1.9.9 I was able to unpack a map that had keys that were a custom extension type (e.g. a python tuple or frozenset) I had defined. Upgrading to 1.10.1 I started seeing the Invalid property type for record error added in 18f44f8.
As discussed below, setting mapsAsObjects: false preserves the original key type. Perhaps this error message could be updated to something like:
Non-string object key. Try using mapsAsObjects: false
The text was updated successfully, but these errors were encountered:
Just to clarify a bit, you are not reading decoding the MessagePack as JS Maps using mapsAsObjects: false, you are decoding them as plain JS objects? And is the latter the preference? Decoding as Map , should still preserve the original key type.
Ah! I didn't realise that was the appropriate way to do this. I'll give that a try next week. If that works, I'd suggest updating the error message to point at that as a way to fix the problem.
LilyFoote
changed the title
Add support for unpacking map keys that aren't strings or numbers
Improve error message when unpacking non-string keys into an object
Jan 15, 2024
I just realised I never got back to you here. Using mapsAsObjects: false did indeed resolve the issue for me. My suggestion to improve the error message to point at this solution still stands.
I'm using msgpack to serialize python data and then I want to unpack that again in my typescript code. In msgpackr 1.9.9 I was able to unpack a map that had keys that were a custom extension type (e.g. a python tuple or frozenset) I had defined. Upgrading to 1.10.1 I started seeing the
Invalid property type for record
error added in 18f44f8.As discussed below, setting
mapsAsObjects: false
preserves the original key type. Perhaps this error message could be updated to something like:Non-string object key. Try using mapsAsObjects: false
The text was updated successfully, but these errors were encountered: