How to write a legit string with JSON object in that?

fn main() {
    let str = "hello; mode={"mode":"open"}";
}

how to make this kind of string legit?

Either escape the quotes:

let str = "hello; mode={\"mode\":\"open\"}";

Or use raw string literals:

let str = r#"hello; mode={"mode":"open"}"#;
1 Like

template string is what I want, thanks!