Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/crowdagger/yaml_extras
Restructure a YAML internal representations so that dotted keys map to inner fields
https://github.com/crowdagger/yaml_extras
Last synced: about 8 hours ago
JSON representation
Restructure a YAML internal representations so that dotted keys map to inner fields
- Host: GitHub
- URL: https://github.com/crowdagger/yaml_extras
- Owner: crowdagger
- License: mpl-2.0
- Created: 2023-08-23T21:01:00.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2023-09-05T01:30:50.000Z (about 1 year ago)
- Last Synced: 2024-10-12T13:45:53.370Z (about 1 month ago)
- Language: Rust
- Size: 60.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# yaml_extras
Misc yaml-related utility functions.
## Restructure
If you use YAML for a configuration file, you might want to allow to use
both things like:```yaml
compiler:
command: cargo build
```and:
```yaml
compiler.command: cargo build
```(Or not. I know *I* needed that. Whatever.)
The functions `restructure_map` and `restructure_from_str` allow just that,
converting dotted keys to inner fiels:```rust
let s1 = r#"
compiler:
command: cargo build
"#;let s2 = r#"
compiler.command: cargo build
"#;
let v1: serde_yaml::Value = serde_yaml::from_str(s1).unwrap();
let v2 = yaml_extras::restructure_from_str(&s2, true).unwrap();
assert_eq!(v1, v2);
```License: MPL-2.0