-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
72 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,14 @@ | ||
[package] | ||
name = "yaml-split" | ||
description = "provides an iterator over individual YAML documents in a YAML file or stream" | ||
version = "0.2.1" | ||
version = "0.2.2" | ||
authors = ["Nathan Essex <nathan@essex.id.au>"] | ||
edition = "2018" | ||
license = "Apache-2.0 OR MIT" | ||
repository = "https://github.com/Nessex/yaml2json-rs" | ||
homepage = "https://github.com/Nessex/yaml2json-rs/blob/master/crates/yaml-split" | ||
categories = ["encoding"] | ||
documentation = "https://docs.rs/yaml-split/" | ||
|
||
[dependencies] | ||
thiserror = "1.0.22" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# yaml-split | ||
|
||
yaml-split is a library which provides an iterator over individual YAML documents in a file or stream. | ||
|
||
For example, you might have a YAML file like the following: | ||
|
||
``` | ||
hello: world | ||
--- | ||
foo: bar | ||
``` | ||
|
||
This file contains two separate YAML documents. yaml-split will provide you the following two values in-order: | ||
|
||
``` | ||
hello: world | ||
``` | ||
|
||
``` | ||
--- | ||
foo: bar | ||
``` | ||
|
||
This output is suitable for use by existing YAML deserializers such as [serde-yaml](https://github.com/dtolnay/serde-yaml). | ||
|
||
## Usage | ||
|
||
``` | ||
let file = File::open(f).unwrap(); | ||
let doc_iter = DocumentIterator::new(file); | ||
for doc in doc_iter { | ||
println!("Doc:\n{}\n", doc); | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# yaml2json-rs | ||
|
||
yaml2json-rs is a library which helps to convert YAML document strings to JSON. Output can be returned as a string, or passed on to anything that implements `io::Write`. | ||
|
||
This library is a thin wrapper around [serde-yaml](https://github.com/dtolnay/serde-yaml) and [serde-json](https://github.com/serde-rs/json). | ||
|
||
## Usage | ||
|
||
``` | ||
let yaml = r#" | ||
hello: world | ||
"#; | ||
let yaml2json = Yaml2Json::new(Style::PRETTY); | ||
let json = yaml2json.document_to_string(yaml); | ||
println!("{}", json); | ||
``` |