mockersf / hocon.rs

Parse HOCON configuration files in Rust
MIT License
78 stars 16 forks source link

Support for 'dashed' property names #34

Closed everson closed 3 years ago

everson commented 3 years ago

Hi, thanks for this project.

I am trying to migrate a project from Scala to Rust and keep the config for backwards compatibility with the automation. I was hoping to be able read our config, which uses dashes to separate words, instead of underlines. Is there a way to accomplish this? I didn't see any configuration knobs.

Example config:

  concurrency: {
    server-threads: 16
    client-threads: 8
    foo-bar: {
       nested-config: true
    }
  }
mockersf commented 3 years ago

Hello, thank you for trying it out!

I tried with your conf snippet, it si loading for me, you can see here

What is the issue you're facing?

everson commented 3 years ago

Oh, Sorry, only after opening this it occurred to me that this setting might be in serde instead:

I was looking at this exact moment to create a minimal snippet for you.

https://serde.rs/attr-rename.html

e.g.

#[derive(Serialize)]
#[serde(rename_all = "kebab-case")]
struct Person {
    first_name: String,
    last_name: String,
}

that works.

everson commented 3 years ago

Thank you a lot. Sorry for the false alarm.