close
The Wayback Machine - https://web.archive.org/web/20220308215339/https://github.com/actix/actix-web/discussions/2686
Skip to content

How decode a struct(json) in from field form? #2686

Unanswered
mamcx asked this question in Q&A
How decode a struct(json) in from field form? #2686
Mar 7, 2022 · 0 answers

I have some struct that need to travel with the form:

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Clock {
    /// An Id that identifies the partition (user, device, etc) that request the change
    pub actor: String,
    /// The version is a monotonical mark of the changes applied to the data
    pub version: usize,
    /// A timestamp in UTC used for last-updated-win semantics.
    pub t: DateTime<Utc>,
}

Clock {
        actor: "system",
        version: 0,
        t: 2022-03-04T19:59:01.970994Z,
    }

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct LineForm {
    pub dot: Clock,
}

Now the problem is that the field is not decoded back:

<input type="hidden" name="dot" value ="{&quot;actor&quot;:&quot;system&quot;,&quot;version&quot;:0,&quot;t&quot;:&quot;2022-03-07T23:41:35.823679Z&quot;}" />`

Replies

0 suggested answers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant