-
Notifications
You must be signed in to change notification settings - Fork 10
Closed
Description
A nullable field should result in an option.Option type
Given this typedef:
{
"properties": {
"page": { "nullable": true, "type": "string" }
}
}the library produces
import decode
import gleam/json
import gleam/option
pub type Data {
Data(
page: String,
)
}
pub fn data_decoder() -> decode.Decoder(Data) {
decode.into({
use page <- decode.parameter
Data(page:)
})
|> decode.field("page", decode.nullable(decode.string))
}
pub fn data_to_json(data: Data) -> json.Json {
json.object([
#("page", json.nullable(data.page, json.string)),
])
}Also, decode.nullable should be decode.optional
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels