{"id":13439403,"url":"https://github.com/chyh1990/yaml-rust","last_synced_at":"2025-05-14T13:08:45.492Z","repository":{"id":32650378,"uuid":"36237516","full_name":"chyh1990/yaml-rust","owner":"chyh1990","description":"A pure rust YAML implementation.","archived":false,"fork":false,"pushed_at":"2024-03-25T12:42:02.000Z","size":990,"stargazers_count":618,"open_issues_count":71,"forks_count":144,"subscribers_count":17,"default_branch":"master","last_synced_at":"2025-04-03T02:07:20.457Z","etag":null,"topics":["rust","yaml-parser"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/chyh1990.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-05-25T15:05:39.000Z","updated_at":"2025-03-22T10:32:02.000Z","dependencies_parsed_at":"2024-06-18T13:39:28.485Z","dependency_job_id":"216e3e42-6979-43b2-a19b-a43e92ba9ade","html_url":"https://github.com/chyh1990/yaml-rust","commit_stats":{"total_commits":200,"total_committers":36,"mean_commits":5.555555555555555,"dds":0.63,"last_synced_commit":"da52a68615f2ecdd6b7e4567019f280c433c1521"},"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chyh1990%2Fyaml-rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chyh1990%2Fyaml-rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chyh1990%2Fyaml-rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chyh1990%2Fyaml-rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chyh1990","download_url":"https://codeload.github.com/chyh1990/yaml-rust/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248154986,"owners_count":21056542,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["rust","yaml-parser"],"created_at":"2024-07-31T03:01:13.617Z","updated_at":"2025-04-10T03:46:39.320Z","avatar_url":"https://github.com/chyh1990.png","language":"Rust","readme":"# yaml-rust\n\nThe missing YAML 1.2 implementation for Rust.\n\n[![Travis](https://travis-ci.org/chyh1990/yaml-rust.svg?branch=master)](https://travis-ci.org/chyh1990/yaml-rust)\n[![AppVeyor](https://ci.appveyor.com/api/projects/status/scf47535ckp4ylg4?svg=true)](https://ci.appveyor.com/project/chyh1990/yaml-rust)\n[![crates.io](https://img.shields.io/crates/v/yaml-rust.svg)](https://crates.io/crates/yaml-rust)\n[![docs.rs](https://img.shields.io/badge/api-rustdoc-blue.svg)](https://docs.rs/yaml-rust)\n\n`yaml-rust` is a pure Rust YAML 1.2 implementation,\nwhich enjoys the memory safety\nproperty and other benefits from the Rust language.\nThe parser is heavily influenced by `libyaml` and `yaml-cpp`.\n\n## Quick Start\n\nAdd the following to the Cargo.toml of your project:\n\n```toml\n[dependencies]\nyaml-rust = \"0.4\"\n```\n\nand import:\n\n```rust\nextern crate yaml_rust;\n```\n\nUse `yaml::YamlLoader` to load the YAML documents and access it\nas Vec/HashMap:\n\n```rust\nextern crate yaml_rust;\nuse yaml_rust::{YamlLoader, YamlEmitter};\n\nfn main() {\n    let s =\n\"\nfoo:\n    - list1\n    - list2\nbar:\n    - 1\n    - 2.0\n\";\n    let docs = YamlLoader::load_from_str(s).unwrap();\n\n    // Multi document support, doc is a yaml::Yaml\n    let doc = \u0026docs[0];\n\n    // Debug support\n    println!(\"{:?}\", doc);\n\n    // Index access for map \u0026 array\n    assert_eq!(doc[\"foo\"][0].as_str().unwrap(), \"list1\");\n    assert_eq!(doc[\"bar\"][1].as_f64().unwrap(), 2.0);\n\n    // Chained key/array access is checked and won't panic,\n    // return BadValue if they are not exist.\n    assert!(doc[\"INVALID_KEY\"][100].is_badvalue());\n\n    // Dump the YAML object\n    let mut out_str = String::new();\n    {\n        let mut emitter = YamlEmitter::new(\u0026mut out_str);\n        emitter.dump(doc).unwrap(); // dump the YAML object to a String\n    }\n    println!(\"{}\", out_str);\n}\n```\n\nNote that `yaml_rust::Yaml` implements `Index\u003c\u0026'a str\u003e` \u0026 `Index\u003cusize\u003e`:\n\n* `Index\u003cusize\u003e` assumes the container is an Array\n* `Index\u003c\u0026'a str\u003e` assumes the container is a string to value Map\n* otherwise, `Yaml::BadValue` is returned\n\nIf your document does not conform to this convention (e.g. map with\ncomplex type key), you can use the `Yaml::as_XXX` family API to access your\ndocuments.\n\n## Features\n\n* Pure Rust\n* Ruby-like Array/Hash access API\n* Low-level YAML events emission\n\n## Specification Compliance\n\nThis implementation aims to provide YAML parser fully compatible with\nthe YAML 1.2 specification. The parser can correctly parse almost all\nexamples in the specification, except for the following known bugs:\n\n* Empty plain scalar in certain contexts\n\nHowever, the widely used library `libyaml` also fails to parse these examples,\nso it may not be a huge problem for most users.\n\n## Goals\n\n* Encoder\n* Tag directive\n* Alias while deserialization\n\n## Minimum Rust version policy\n\nThis crate's minimum supported `rustc` version is 1.31 (released with Rust 2018, after v0.4.3), as this is the currently known minimum version for [`regex`](https://crates.io/crates/regex#minimum-rust-version-policy) as well.\n\n## License\n\nLicensed under either of\n\n * Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)\n * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)\n\nat your option.\n\n## Contribution\n\nFork \u0026 PR on Github.\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any\nadditional terms or conditions.\n","funding_links":[],"categories":["Libraries","Rust","库 Libraries","库"],"sub_categories":["Encoding","编码 Encoding","加密 Encoding","编码(Encoding)"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchyh1990%2Fyaml-rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchyh1990%2Fyaml-rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchyh1990%2Fyaml-rust/lists"}