Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Response using Adjacently tag #50

Closed
whylee259 opened this issue Dec 29, 2020 · 0 comments
Closed

Remove Response using Adjacently tag #50

whylee259 opened this issue Dec 29, 2020 · 0 comments
Assignees
Labels

Comments

@whylee259
Copy link
Contributor

whylee259 commented Dec 29, 2020

It seems for us to be able to use the Adjacently tag and the deserializer of derive


I wonder why this uses a manually implemented deserializer rather than use derive as follows.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(untagged)]
pub enum Token {
    FT(FungibleToken),
    NFT(NonFungibleToken),
}

Additionally, using Adjacently tag, seems to be able to reduce the depth of response struct.

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(tag = "type", content = "value")]
pub enum Token {
    #[serde(rename = "collection/FT")]
    FT(FungibleToken),
    #[serde(rename = "collection/NFT")]
    NFT(NonFungibleToken),
}

let res = serde_json::from_str::<Vec<Token>>(json);

but we can discuss reducing depth on another issue.

Originally posted by @whylee259 in #35 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant