#yaml #hash-map #merge #capabilities #linked #value #linked-hash-map

merge-yaml-hash

YAML Hash with merge/update capabilities

6 releases (3 breaking)

0.4.0 Jul 31, 2024
0.3.0 Nov 21, 2023
0.2.0 Oct 18, 2019
0.1.3 Oct 15, 2019

#483 in Encoding

Download history 70/week @ 2024-09-21 77/week @ 2024-09-28 115/week @ 2024-10-05 35/week @ 2024-10-12 66/week @ 2024-10-19 32/week @ 2024-10-26 102/week @ 2024-11-02 61/week @ 2024-11-09 50/week @ 2024-11-16 62/week @ 2024-11-23 26/week @ 2024-11-30 82/week @ 2024-12-07 85/week @ 2024-12-14 9/week @ 2024-12-21 65/week @ 2024-12-28 110/week @ 2025-01-04

280 downloads per month
Used in 3 crates (2 directly)

MIT license

13KB
218 lines

About

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.

Example

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",
);

Changelog

  • 0.1.0 (2019-10-15): Initial release
  • 0.1.1-3 (2019-10-15): Minor fixes
  • 0.2.0 (2019-10-18): Make data field public
  • 0.3.0 (2023-11-21): Resolve issue #1; update edition and dependencies; apply clippy suggestions; modernize
  • 0.4.0 (2024-07-31): Add recommendation to use yaml-hash instead, which uses yaml-rust2 versus unmaintained yaml-rust; fix makefile; fix changelog; update dependencies

Dependencies

~185KB