mirror of
https://github.com/nushell/nushell.git
synced 2024-11-24 17:34:00 +01:00
1e2fa68db0
Bumps [fancy-regex](https://github.com/fancy-regex/fancy-regex) from 0.13.0 to 0.14.0. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/fancy-regex/fancy-regex/releases">fancy-regex's releases</a>.</em></p> <blockquote> <h2>0.14.0</h2> <h3>Added</h3> <ul> <li>Add <code>split</code>, <code>splitn</code> methods to <code>Regex</code> to split a string into substrings (<a href="https://redirect.github.com/fancy-regex/fancy-regex/issues/140">#140</a>)</li> <li>Add <code>case_insensitive</code> method to <code>RegexBuilder</code> to force case-insensitive mode (<a href="https://redirect.github.com/fancy-regex/fancy-regex/issues/132">#132</a>)</li> </ul> <h3>Changed</h3> <ul> <li>Bump bit-set dependency to 0.8 (<a href="https://redirect.github.com/fancy-regex/fancy-regex/issues/139">#139</a>)</li> </ul> </blockquote> </details> <details> <summary>Changelog</summary> <p><em>Sourced from <a href="https://github.com/fancy-regex/fancy-regex/blob/main/CHANGELOG.md">fancy-regex's changelog</a>.</em></p> <blockquote> <h2>[0.14.0] - 2024-10-24</h2> <h3>Added</h3> <ul> <li>Add <code>split</code>, <code>splitn</code> methods to <code>Regex</code> to split a string into substrings (<a href="https://redirect.github.com/fancy-regex/fancy-regex/issues/140">#140</a>)</li> <li>Add <code>case_insensitive</code> method to <code>RegexBuilder</code> to force case-insensitive mode (<a href="https://redirect.github.com/fancy-regex/fancy-regex/issues/132">#132</a>)</li> </ul> <h3>Changed</h3> <ul> <li>Bump bit-set dependency to 0.8 (<a href="https://redirect.github.com/fancy-regex/fancy-regex/issues/139">#139</a>)</li> </ul> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href=" |
||
---|---|---|
.. | ||
src | ||
tests | ||
Cargo.toml | ||
CHANGELOG.md | ||
LICENSE | ||
README.md |
nu-json
a fork of serde_hjson.
The changes made to this crate are kept in CHANGELOG.
The Rust implementation of Hjson is based on the Serde JSON Serialization Library.
This crate is a Rust library for parsing and generating Human JSON Hjson. It is built upon Serde, a high performance generic serialization framework.
Install
This crate works with Cargo and can be found on crates.io with a Cargo.toml
like:
[dependencies]
serde = "1"
nu-json = "0.76"
From the Commandline
Add with:
cargo add serde
cargo add nu-json
Usage
extern crate serde;
extern crate nu_json;
use nu_json::{Map,Value};
fn main() {
// Now let's look at decoding Hjson data
let sample_text=r#"
{
## specify rate in requests/second
rate: 1000
array:
[
foo
bar
]
}"#;
// Decode and unwrap.
let mut sample: Map<String, Value> = nu_json::from_str(&sample_text).unwrap();
// scope to control lifetime of borrow
{
// Extract the rate
let rate = sample.get("rate").unwrap().as_f64().unwrap();
println!("rate: {}", rate);
// Extract the array
let array : &mut Vec<Value> = sample.get_mut("array").unwrap().as_array_mut().unwrap();
println!("first: {}", array.first().unwrap());
// Add a value
array.push(Value::String("baz".to_string()));
}
// Encode to Hjson
let sample2 = nu_json::to_string(&sample).unwrap();
println!("Hjson:\n{}", sample2);
}
DOCS
At the moment, the documentation on serde_hjson / serde_json is also relevant for nu-json.