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!

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.