'How to read response JSON as structs when they contain hyphens in key names?

I am querying an API for some data but their keys have hyphens instead of underscores in their names, and since I can't have hyphens in struct field names, I am unable to cast it.

For example, my struct:

pub struct Example {
    user_id: String,
    name: String,
}

and the received json is like

{
    "user-id": "abc",
    "name": "John"
}

Right now i'm doing this but i can't because i can't directly cast it

let res = client
    .get("SOME-URL")
    .header("x-api-key", APP_ID)
    .send()
    .await?;

let response_body: Example = res.json().await?;


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source