extract_jsons_from_string

Crates.ioextract_jsons_from_string
lib.rsextract_jsons_from_string
version0.1.3
sourcesrc
created_at2023-04-18 08:09:19.398181
updated_at2023-04-18 08:39:50.749866
descriptionA library to extract valid JSONs from a string to a vector
homepage
repositoryhttps://github.com/at-75/extract_jsons_from_string
max_upload_size
id842284
size4,552
Abhishek (at-75)

documentation

README

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);
    }
}
Commit count: 32

cargo fmt