#How do I decode `type`?
1 messages · Page 1 of 1 (latest)
What's stopping you decoding it?
I cannot have a struct paramater named type
Name it something else then
import gleam/dynamic
pub type ReceiveTag {
ReceiveTag(name: String, value: String, media_type: String)
}
pub fn receive_encoder() {
dynamic.decode3(
ReceiveTag,
dynamic.field("name", dynamic.string),
dynamic.field("value", dynamic.string),
dynamic.field("type", dynamic.string),
)
}
like can I do this?
Yep
Why would it?
Although you should use the new decoder API, that one will soon be deprecated
what is the new decoder API?
Not the decoder they need though
Pretty close
Why not?
Because the JSON field is called type but the Gleam field is called media_type
By default it assumes all the fields match up
how would I prompt that?
I do not see any code actions near the type