Skip to content

An example on how to deserialize to a struct or hashmap? #62

Answered by gklijs
ultrabug asked this question in Q&A
Discussion options

You must be logged in to vote

It depends a lot on whether you know the schema of the data up front. If you don't you get back a Value::Record which contains the values, but can be tedious to get the information from. Like in

async fn test_decoder_default() {
you then would need to match for the vector to contain some field with the expected name, and the expected kind of value, then read the value.

If you do know the schema you can do something similar to

let item = match from_value::<Heartbeat>(&heartbeat) {

using the struct defined

Replies: 2 comments 12 replies

Comment options

You must be logged in to vote
8 replies
@ultrabug
Comment options

@gklijs
Comment options

@ultrabug
Comment options

@ultrabug
Comment options

@ultrabug
Comment options

Answer selected by gklijs
Comment options

You must be logged in to vote
4 replies
@e-osuna-g
Comment options

@gklijs
Comment options

@e-osuna-g
Comment options

@gklijs
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants