For example, If I have {"name": "jhon", "new_user": {}}
How can I see If new_user key is present?
I tried using unit struct but got error
Error: Error("invalid type: map, expected unit struct NewUser", line: 1, column: 29)
use serde_json::Result;
use serde::Deserialize;
#[derive(Debug, Deserialize)]
struct NewUser;
#[derive(Debug, Deserialize)]
struct Response {
name: String,
new_user: NewUser
}
fn main() -> Result<()>{
let text = r#"{"name": "jhon", "new_user": {}}"#;
let resp: Response = serde_json::from_str(text)?;
println!("{:?}", resp);
Ok(())
}