I try to create a JSON object with serde_json::json!
but the problem is that I get \"
but I don't want them. How can I prevent or remove them?
fn create_cache_json(token: &str, change: &str, payload: Vec<Value>) -> Value {
let json = serde_json::json!(
{
"token": token,
"change": change,
"data": {
"payload": payload
}
});
info!("{}", json);
return json;
}
this code returns
{
"change": "\"new\"",
"data": {
"payload":[]
},
"token": "\"2a256356\""
}
EDIT: The input values are:
fn main() {
let token: &str = "foo".to_string();
let change: &str = "new".to_string();
let payload: Vec<serde_json::Value> = Vec::new();
create_cache_json(token, change, payload);
}
The input are literals that already have quotes.
The token output is: "foo"
but it should be foo
.
Using crates like quote
don't work because the values have to be strings.
For this function should the payload be empty.