Function json_strip_comments::strip_comments_in_place

source ยท
pub fn strip_comments_in_place(
    s: &mut str,
    settings: CommentSettings,
    remove_trailing_commas: bool,
) -> Result<()>
Expand description

Strips comments from a string in place, replacing it with whitespaces.

/// ## Example

use json_strip_comments::{strip_comments_in_place, CommentSettings};

let mut string = String::from(r#"{
// c line comment
"a": "comment in string /* a */",
# shell line comment
} /** end */"#);

strip_comments_in_place(&mut string, CommentSettings::default(), false).unwrap();

assert_eq!(string, "{
                 \n\"a\": \"comment in string /* a */\",
                    \n}           ");