serde-wasm-bindgen: #[serde(alias = "somename")] stopped working after 0.6

After when going from 0.5 to 0.6 it looks like alias is broken

Using:

wasm-bindgen = "0.2.91"
serde = { version = "1.0.196", features = ["derive"] }
serde_json = "1.0.113"
serde-wasm-bindgen = "0.6.3" //0.5 works... fails if i go higher
console_error_panic_hook="0.1.7"
#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum FilterAction {
    Append,
    Remove,
    Keep,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub enum FilterType {
    Standard,
    Boundingbox,
}

#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct FilterInput {
    #[serde(alias = "filtertype")]
    pub filter_action: FilterAction,
    #[serde(alias = "type")]
    pub filter_type: FilterType,
    ...

This is my input image

get error:

panicked at src\lib.rs:228:58:
called `Result::unwrap()` on an `Err` value: Error(JsValue(Error: unknown variant `Append`, expected `Standard` or `Boundingbox`
Error: unknown variant `Append`, expected `Standard` or `Boundingbox`

Its like its setting values from json filtertype to rust filter_type when it should have used json type.

Is it a bug or have I just been lucky it been working ?

About this issue

  • Original URL
  • State: closed
  • Created 4 months ago
  • Comments: 15 (8 by maintainers)

Most upvoted comments

Fixed in 0.6.4. Thanks for the report!