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 think this is related to serde-rs/serde#723 which seems to not be resolved yet.
I have a JSON response I want to deserialize, but I want the keys of a particular hashmap to be case-insensitive.
The following throws an error (mismatched types, expected vec etc), and I think I understand why:
#[serde(default, with = "unicase_serde::unicase")]
results: Vec<HashMap<UniCase<String>, Option<String>>>
I don't think I can use that "with" line unless the following type is a straight-up UniCase, which it is not, though it contains one.
Is what I'm attempting possible right now? My fallback is to do some slow upper/lower casing over the whole structure after the initial deserialization to String. Not ideal, but I'll survive.
The text was updated successfully, but these errors were encountered:
No, you can't do this at the moment unfortunately. You are right that it relates to serde-rs/serde#723.
The current workaround involves writing some painful wrapper types and then manually implementing Serialize and Deserialize for them.
structWrapperString(pubUniCase<String>);
In this case, it will help if you impl Deref for this type so that you can call the methods of the wrapped type easier without having to resort to test_string.0.method().
If you are not sure how to proceed from here, I can cook up some example code for you.
Thank you for your reply and offer. For the moment I will just make-do with case sensitivity, it's not entirely necessary for my use case, just very nice to have.
I'll revisit if progress is made with that serde issue!
To add on, FWIW, I have commented on seanmonstar/unicase#41 to try and get this functionality implemented directly in the unicase crate so that we don't have to workaround this.
(note: I'm new to Rust)
I think this is related to serde-rs/serde#723 which seems to not be resolved yet.
I have a JSON response I want to deserialize, but I want the keys of a particular hashmap to be case-insensitive.
The following throws an error (mismatched types, expected vec etc), and I think I understand why:
I don't think I can use that "with" line unless the following type is a straight-up UniCase, which it is not, though it contains one.
Is what I'm attempting possible right now? My fallback is to do some slow upper/lower casing over the whole structure after the initial deserialization to String. Not ideal, but I'll survive.
The text was updated successfully, but these errors were encountered: