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

Serialization of flatten type not supported #20

Closed
whalelephant opened this issue Sep 14, 2020 · 4 comments · Fixed by #50
Closed

Serialization of flatten type not supported #20

whalelephant opened this issue Sep 14, 2020 · 4 comments · Fixed by #50

Comments

@whalelephant
Copy link

Reference to: CosmWasm/cw-plus#57

The #[serde(flatten)] serializes with serialize_struct_as_map, however, this lib does not fully implement the SerializeMap function.

This issue can be replicated when one uses cosmwasm_std::to_vec() on a struct with the flatten attribute

12: <&mut serde_json_wasm::ser::Serializer as serde::ser::Serializer>::serialize_map
             at /.../serde-json-wasm-0.2.1/src/ser/mod.rs:376
  13: cw20::query::_::<impl serde::ser::Serialize for cw20::query::AllowanceInfo>::serialize
             at packages/cw20/src/query.rs:71
  14: serde_json_wasm::ser::to_vec
             at /.../serde-json-wasm-0.2.1/src/ser/mod.rs:422
  15: cosmwasm_std::serde::to_vec
             at /.../cosmwasm-std-0.10.1/src/serde.rs:23
@ethanfrey
Copy link
Member

Thank you for this issue and your research on the item. Good find

@maurolacy
Copy link

maurolacy commented Nov 23, 2020

Not sure if strictly related to this, but I've noticed there's now map ser/de support in the upstream crate (serde-json-core).

I can integrate it if you think it's worth it / would help fix this.

@therne
Copy link

therne commented Apr 21, 2022

@ethanfrey now it's been a while since the upstream added map support, which means that flatten can be used (meaning a lot of CW codes can be refactored) — is there any plans to update it?

@webmaster128
Copy link
Member

Map support was just merged to main. In order to close this ticket, I think we should have explicit #[serde(flatten)] tests that show the input als Rust struct and the expected output as plain JSON.

aumetra pushed a commit that referenced this issue Jul 26, 2024
20: fix warnings; bump heapless; add crate status r=japaric a=japaric

closes #19

Co-authored-by: Jorge Aparicio <jorge@japaric.io>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants