Thanks to visit codestin.com
Credit goes to github.com

Skip to content

lpil/gserde

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gserde

warning: alpha package with poor code hygiene, including assert/panic/todo statements. Use understanding that this package is not ready for primetime.

Package Version Hex Docs

gleam add gserde

usage

  1. Create custom type with a singular variant constructor:
  2. Run gleam run -m gserde
  3. Observe src/foo_json.gleam, which has the goodies you need for json (de)serialization.
// src/foo.gleam
import gleam/option.{type Option}
pub type FooJSON {
  Foo(
    a_bool: Bool,
    b_int: Int,
    c_float: Float,
    d_two_tuple: #(Int, String),
    e_option_int: Option(Int),
    f_string_list: List(String),
  )
}

// src/my_module.gleam
import foo
import foo_json

pub fn serialization_identity_test() {
  let foo_1 = foo.Foo(..)

  let foo_2 = foo_1
    |> foo_json.to_string // 👀
    |> foo_json.from_string // 👀

  foo_1 == foo_2
}

todo

  • complete all cases
  • remove all invocations of assert/panic/todo
  • support non-gleam primitive types
  • handle all module references properly

Further documentation can be found at https://hexdocs.pm/gserde.

Development

gleam test  # Run the tests

About

gleam codegen for serialization and deserialization

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Gleam 100.0%