| Crates.io | merge-yaml-hash |
| lib.rs | merge-yaml-hash |
| version | 0.4.0 |
| created_at | 2019-10-15 17:22:04.720324+00 |
| updated_at | 2024-07-31 13:12:02.263075+00 |
| description | YAML Hash with merge/update capabilities |
| homepage | |
| repository | https://github.com/qtfkwk/merge-yaml-hash |
| max_upload_size | |
| id | 172728 |
| size | 17,233 |
YAML Hash with merge/update capabilities
Wrapper around yaml_rust::yaml::Hash, which is a type alias for
linked_hash_map::LinkedHashMap
NOTE: Highly recommend using yaml-hash instead of this crate since it uses yaml-rust2
versus the unmaintained yaml-rust.
Also, it provides additional functionality, including recursive get value via dotted key.
use merge_yaml_hash::{MergeYamlHash, Yaml};
let mut hash = MergeYamlHash::new();
// Merge YAML data from strings
hash.merge("apple: 1\nbanana: 2");
hash.merge("cherry:\n sweet: 1\n tart: 2");
assert_eq!(
hash.to_string(),
"apple: 1\nbanana: 2\ncherry:\n sweet: 1\n tart: 2",
);
// Merge YAML data from file
// * Note that insertion order is maintained
hash.merge("tests/c.yaml"); // "banana: 3"
assert_eq!(
hash.to_string(),
"apple: 1\nbanana: 3\ncherry:\n sweet: 1\n tart: 2",
);
data field publicyaml-hash instead, which uses yaml-rust2 versus unmaintained yaml-rust; fix makefile; fix changelog; update dependencies