-
Notifications
You must be signed in to change notification settings - Fork 741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Multiple external field names #61
Comments
Of course EC2 would have inconsistent names. Why make things simple for us? So (a) looks good in general, though it's a bit strange that we can't roundtrip the format using this scheme. Do you think if we had specialization it could work for this? And yuck! 5 minutes? That could be a useful stress test to help optimize the type checker. Do you have it online somewhere? |
I pushed the rust AWS lib. Note this is still very much a work in progress. It depends on #62 and #39. |
Allows different field names to be used for different external formats. Field names are specified using the `rename` field attribute, e.g: #[serde(rename(xml= "a4", json="a5"))] Reverts serde-rs#62 Addresses serde-rs#61
Allows different field names to be used for different external formats. Field names are specified using the `rename` field attribute, e.g: #[serde(rename(xml= "a4", json="a5"))] Reverts serde-rs#62 Addresses serde-rs#61
@hugoduncan: #69 landed, so is this safe to close? |
I think so. |
…d deserializing According to serde-rs#61, if one uses serde to serialize requests that pass url-encoded parameters to a server, it might get responses back with a different capitalization scheme. This patch restores the behavior implemented in serde-rs#61.
…d deserializing According to serde-rs#61, if one uses serde to serialize requests that pass url-encoded parameters to a server, it might get responses back with a different capitalization scheme. This patch restores the behavior implemented in serde-rs#62.
…d deserializing According to serde-rs#61, if one uses serde to serialize requests that pass url-encoded parameters to a server, it might get responses back with a different capitalization scheme. This patch restores the behavior implemented in serde-rs#62. # Conflicts: # serde_codegen/src/attr.rs # serde_codegen/src/de.rs # serde_tests/tests/test_annotations.rs
I'm using serde to interact with Amazon's EC2 API. The API uses url-encoded parameters on input and returns XML. I am using serde for both serialisation and deserialisation. However, the field names expected by EC2 on input are different from the field names returned in the XML.
I can see several ways of solving this:
a) Extend serde to allow renaming fileds differently on serialisation and on deserialisation, possibly via
rename_ser
andrename_de
annotations.b) Extend serde to allow
Serialiser
specific field encodings.c) Create parallel data structures for input and output data.
Option c) obviously does not require any change in serde, but I'm reluctant to go this route, as it involves significant extra code (there are approx 650 structs used in the EC2 api), particularly in order to hide the duplication in the exposed api, and compile times are already awful (>5mins).
Option a) seems relatively simple to implement, but adds some complexity to serde. Cognitive complexity can be limited by keeping the
rename
annotation for the case where the field names are identical for both serialisation and deserialisation.Option b) seems the most flexible, but would probably add more complexity to serde, espescially for implementors of
Serializer
, and would likely incur extra runtime overhead.Would either of a) or b) be considered for serde?
The text was updated successfully, but these errors were encountered: