Jason parses and generates JSON in Elixir with strong performance versus other BEAM libraries. Parser and generator follow RFC 8259 and ECMA 404.
Overview
Jason is a JSON library written entirely in Elixir for decoding and encoding JSON text. Its parser and generator are designed for speed on the BEAM, with benchmarks reported against other Elixir and Erlang JSON implementations and comparisons to C-based NIF libraries.
Conformance tests cover RFC 8259 and ECMA 404, including the JSONTestSuite. It installs as a Mix dependency and integrates with common ecosystem stacks: Postgrex, Ecto, Plug, Phoenix, and Absinthe can use it as their JSON codec when configured.
Compared to Poison, Jason enforces stricter JSON string rules, requires explicit Jason.Encoder implementations for structs, and offers Jason.Fragment to embed already-encoded JSON without extra round trips. Custom encoders can be derived for owned structs or added via protocol derivation for third-party types.
Benchmarks and HTML reports live in the project’s bench tooling for encode and decode scenarios.
Key features
- RFC 8259 compliant parser
- Fast Elixir-native implementation
- Phoenix and Ecto integration
- Struct encoding via protocols
- Jason.Fragment for pre-encoded JSON
- Bench tooling for comparisons
- Strict JSON string validation
- Mix package installation
Use cases
- Default JSON in Phoenix APIs
- Ecto and Postgrex serialization
- High-throughput JSON APIs
- Caching encoded JSON fragments
- Replacing older Elixir JSON libs