Skip to content

HashMap value as any type #62

@paydii

Description

@paydii

Hey, thanks for this. It's been really useful.

I'm trying to convert a dynamic metadata field that will be unkown of type as the value, but the key will always be a string.

#[derive(Serialize, Deserialize, Debug)]
#[tsync]
pub struct Transaction {
    pub id: i32,
    pub amount: i32,
    pub formatted_amount: String,
    pub transaction_type: String,
    pub description: String,
    pub balance_after: i32,
    pub reference: Option<TransactionReference>,
    pub metadata: Option<HashMap<String, String>>,
    pub created_at: String,
    pub credit: bool,
    pub debit: bool,
}

I found this issue but not sure if it explains my case. What I tried are change the type to Option<HashMap<String, Value>> and pub metadata: Option<Value>, to no succeed. They were generated as metadata?: Value; which is unkown type.

Is this possible at all?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions