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

Special characters in field names should be escaped #29

Open
Patryk27 opened this issue Oct 7, 2022 · 1 comment
Open

Special characters in field names should be escaped #29

Patryk27 opened this issue Oct 7, 2022 · 1 comment
Labels
A-printer Area: pretty-printers C-bug Category: bug

Comments

@Patryk27
Copy link
Collaborator

Patryk27 commented Oct 7, 2022

This code:

use serde::Serialize;

#[derive(Default, Serialize)]
struct Foo {
    #[serde(rename = "bar\"")]
    bar: String,
}

fn main() {
    println!("{}", serde_json::to_string_pretty(&Foo::default()).unwrap());
}

... returns:

{
  "bar\"": ""
}

... but Doku will document it in a wrong way:

{
  "bar"": "string"
}
@Patryk27 Patryk27 added C-bug Category: bug A-printer Area: pretty-printers labels Oct 7, 2022
@Patryk27
Copy link
Collaborator Author

Patryk27 commented Oct 7, 2022

(we already have the escaping logic implemented as a part of value_to_string.rs, so my rough guess is that we should just re-use it to escape all keys before passing them into the printer.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-printer Area: pretty-printers C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

1 participant