Skip to content

A package for keeping your JSON encoders and decoders in sync.

License

Notifications You must be signed in to change notification settings

gleam-community/codec

Repository files navigation

gleam-community/codec

A package for keeping your JSON encoders and decoders in sync.

Package Version Hex Docs

✨ This project is written in pure Gleam so you can use it anywhere Gleam runs: Erlang, Elixir, Node, Deno, and the browser!


Quickstart

import gleam_community/codec

pub type Colour {
  RGB(Int, Int, Int)
  Name(String)
}

pub fn colour_codec() {
  codec.custom2(fn(rgb, name, value) {
    case value {
      RGB(r, g, b) -> rgb(r, g, b)
      Name(n) -> name(n)
    }
  })
  |> codec.variant3("RGB", RGB, codec.int(), codec.int(), codec.int())
  |> codec.variant1("Name", Name, codec.string())
  |> codec.construct
}

Installation

gleam-community packages are published to hex.pm with the prefix gleam_community_. You can add them to your Gleam projects directly:

gleam add gleam_community_codec

The docs can be found over at hexdocs.pm.

About

A package for keeping your JSON encoders and decoders in sync.

Resources

License

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages