#json #string #extract #vector #valid #age #jsons

bin+lib extract_jsons_from_string

A library to extract valid JSONs from a string to a vector

4 releases

0.1.3 Apr 18, 2023
0.1.2 Apr 18, 2023
0.1.1 Apr 18, 2023
0.1.0 Apr 18, 2023

#33 in #age

38 downloads per month

MIT/Apache

5KB
61 lines

About

extract_json_from_string is library to extract valid JSONs from a string and store them in an vector

Usage

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);
    }
}

lib.rs:

Extract_JSON_from_string

Extract_JSON_from_string is library to extract JSONs in a string into a Vector

No runtime deps