#json #string #format-json #serde

json_string

Format JSON string so that serde_json can understand it

10 releases

new 0.1.10 Dec 17, 2024
0.1.9 Dec 17, 2024
0.1.1 Nov 15, 2024

#1116 in Encoding

Download history 250/week @ 2024-11-15 31/week @ 2024-11-22 4/week @ 2024-11-29 15/week @ 2024-12-06

300 downloads per month

MIT/Apache

37KB
777 lines

Formats a given string so that serde_json crate can understand it.

Example 1

use serial_test::serial;
use json_string::prepare_json_string;

let original_str = r#"
    [
        {"tag":"lol", "groups":[]}
    ]
"#;
let prepared_str = prepare_json_string(original_str);

let expected_str = r#"[{"tag": "lol"}]"#;

assert_eq!(prepared_str, expected_str);

Example 2

use serial_test::serial;
use json_string::prepare_json_string;

let original_str = r#"
    [
        {"label":"lol", "customtags": {"k1": "v1"}}
    ]
"#;
let prepared_str = prepare_json_string(original_str);

let expected_str = r#"[{"label": "lol", "customtags": {"k1": "v1"}}]"#;

assert_eq!(prepared_str, expected_str);

Dependencies

~3.5–9MB
~100K SLoC