Crates.io | extract_jsons_from_string |
lib.rs | extract_jsons_from_string |
version | 0.1.3 |
source | src |
created_at | 2023-04-18 08:09:19.398181 |
updated_at | 2023-04-18 08:39:50.749866 |
description | A library to extract valid JSONs from a string to a vector |
homepage | |
repository | https://github.com/at-75/extract_jsons_from_string |
max_upload_size | |
id | 842284 |
size | 4,552 |
extract_json_from_string is library to extract valid JSONs from a string and store them in an vector
use extract_jsons_from_string::extract;
fn main() {
let data = r#"sample text before json {
"name": "Abigail",
"age": 34,
"isMarried": true,
"hobbies": ["reading", "gardening"]
} sample text after json
{
"name": "Morris",
"age": 45,
"isMarried": false,
"hobbies": ["cycling", "swimming"]
} sample text after json
"#;
let v: Vec<String> = extract(data);
// Output : {"name":"Abigail","age":34,"isMarried":true,"hobbies":["reading","gardening"]}
// {"name":"Morris","age":45,"isMarried":false,"hobbies":["cycling","swimming"]}
for s in &v {
println!("{}", s);
}
}