cbor
cbor copied to clipboard
Allow integer map keys to accept string-encoded integers
This fixes #205. I know this project is semi-abandoned and you don't want to add code you haven't read (totally understandable) so let me know if you think this will never be merged and in that case I guess we will have to fork this.
Note most of the code for impl<'de, 'a, R> de::Deserializer<'de> for MapKey<'a, R>
was copied from serde_json
.
When serde attempts to deserialise a HashMap<i32, T> for example, with serde_json it will accept keys that are string-encoded versions of integers. This is because JSON only supports string keys. However this means that when you save data using serde_json, convert it to CBOR and then try and read it using serde_cbor, it will fail because CBOR does not accept string-encoded integer keys.
This commit changes that so that it does.
Also I'm not exactly sure what accept_packed
/accept_named
are so this might not be right if either of those are disabled.