Skip to content
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

Regression in crossterm 0.21.0: Deserialize Color and Serialize Color produces different values #601

Closed
sigmaSd opened this issue Sep 13, 2021 · 4 comments

Comments

@sigmaSd
Copy link
Contributor

sigmaSd commented Sep 13, 2021

    use crossterm::style::Color;
    let color = Color::Red;
    serde_json::from_str::<Color>(&serde_json::to_string(&Color::DarkBlue).unwrap()).unwrap();

panics with invalid value: string \"DarkBlue\", expected `black`, `blue`, `dark_blue`, `cyan`, `dark_cyan`, `green`, `dark_green`, `grey`, `dark_grey`, `magenta`, `dark_magenta`, `red`, `dark_red`, `white`, `yellow`, `dark_yellow`, `u8`, or `3 u8 array`

pinging pr #576 author @zwpaper

@zwpaper
Copy link
Contributor

zwpaper commented Sep 13, 2021

hi @sigmaSd, thanks for use crossterm, the problem you mentioned is caused by 3 reasons:

  1. The panic is caused by the unwrap you used
  2. It is by design to return error when deserialized an unknown color
  3. Serialization use CamelCase by default but deserialization under_lined, I will look into it later

@sigmaSd
Copy link
Contributor Author

sigmaSd commented Sep 13, 2021

Hello, yes its just an demo example, the problem I'm pointing at (as the title says) is the 3rd one.

@TimonPost
Copy link
Member

That doesnt look correct. Let me give it a shot im going to do some maintenance today.

@sigmaSd
Copy link
Contributor Author

sigmaSd commented Oct 21, 2021

fixed #604

@sigmaSd sigmaSd closed this as completed Oct 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants