gleerup
Simple Syrup encoder and decoder for Gleam.
gleam add gleerup@1
import gleerup
import gleerup/denc
pub fn main() -> Nil {
let input = <<"{7\"another[1+2+3+]3\"age30+4\"name5\"Alice7\"isAlivet}">>
let result = denc.decode(input) |> default_value
assert gleerup.Dictionary(
dict.from_list([
#(gleerup.String("age"), gleerup.PositiveInteger(30)),
#(gleerup.String("name"), gleerup.String("Alice")),
#(gleerup.String("isAlive"), gleerup.Boolean(True)),
#(
gleerup.String("another"),
gleerup.Sequence([
gleerup.PositiveInteger(1),
gleerup.PositiveInteger(2),
gleerup.PositiveInteger(3),
]),
),
]),
)
== result
}
Further documentation can be found at https://hexdocs.pm/gleerup.
Development
gleam run # Run the project
gleam test # Run the tests