• Stars
    star
    130
  • Rank 267,810 (Top 6 %)
  • Language
    Erlang
  • License
    Other
  • Created over 4 years ago
  • Updated about 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A blazing fast JSON parser and generator in pure Erlang.

Thoas

A blazing fast JSON parser and generator in pure Erlang.

Thoas is an Erlang conversion of the Elixir based Jason library.

The parser and generator are at least twice as fast as other Elixir/Erlang libraries. The performance is comparable to jiffy, which is implemented in C as a NIF. Thoas and Jason are usually only twice as slow.

Both parser and generator fully conform to RFC 8259 and ECMA 404 standards. The parser is tested using JSONTestSuite.

If you like this library thank Michał and the Jason contributors. They did all the hard work!

Installation

Erlang

% rebar.config
{deps, [thoas]}

Gleam

gleam add thoas

Elixir

# mix.exs
def deps do
  [{:thoas, "~> 1.0"}]
end

Basic Usage

> thoas:encode(#{age => 44, name => <<"Steve Irwin">>, nationality => <<"Australian">>}).
<<"{\"age\":44,\"name\":\"Steve Irwin\",\"nationality\":\"Australian\"}">>

> thoas:decode(<<"{\"age\":44,\"name\":\"Steve Irwin\",\"nationality\":\"Australian\"}">>).
{ok, #{<<"age">> => 44, <<"name">> => <<"Steve Irwin">>, <<"nationality">> => <<"Australian">>}}

Erlang <-> JSON mapping

Erlang JSON
null null
true true
false false
nil "nil"
undefined "undefined"
other_atom "other_atom"
1 1
1.1 1.1
-2.0 -2.0
[] []
[1, 2] [1,2]
"chars" [99,104,97,114,115]
<<"text">> "text"
<<"\n">> "\\n"
#{} {}
#{<<"name">> => <<"Lucy">>} {"name":"Lucy"}
#{score => 42, win => true} {"score":42,"win":true}
[{proplists, true}] {"proplists":true}

Benchmarks

Benchmarks against most popular Elixir & Erlang json libraries can be executed after going into the bench/ folder and then executing mix bench.encode and mix bench.decode. A HTML report of the benchmarks (after their execution) can be found in bench/output/encode.html and bench/output/decode.html respectively.

Differences to Jason

Thoas has some feature differences compared to Jason.

  • Thoas is written in Erlang.
  • Thoas has no support for Elixir protocols.
  • Thoas has no support for pretty-printing JSON.
  • Thoas has no support for detecting duplicate object keys.
  • Thoas has no support for decoding objects to ordered dictionaries.
  • Thoas has no support for decoding object keys as atoms.
  • Thoas has no support for decoding floats to Elixir decimals.
  • Thoas has an additional non-recursive encoder API that may be useful when working within statically typed languages such as Gleam.

Why not use Jason?

Jason rocks, but if you're writing Erlang, Gleam, or some other BEAM language you probably don't want to pull in the Elixir compiler and their standard libraries just to get a really fast JSON parser. Thoas is just Erlang and uses rebar3, so it can be easily added as a dependency to projects written in any BEAM language.

Thoas also has a non-recursive API that may be useful from statically typed languages or in highly performance constrained scenarios.

Why is it called Thoas?

Thoas is a son of Jason.

License

Thoas is released under the Apache License 2.0 - see the LICENSE file.

Thoas is based off of Jason, which is also Apache 2.0 licenced.

Some elements of tests and benchmarks have their origins in the Poison library and were initially licensed under CC0-1.0.

More Repositories

1

mix-test.watch

🎠 Because TDD is awesome
Elixir
867
star
2

dogma

🔐 A code style linter for Elixir
Elixir
472
star
3

exfmt

🌸 An opinionated Elixir source code formatter
Elixir
439
star
4

sonic-pi-tool

🎻 Controlling Sonic Pi from the command line
Rust
200
star
5

rustexp

A Rust regular expression editor and tester that runs entirely within the browser!
Rust
109
star
6

elixre

🦑 An Elixir regular expression editor & tester, with Elm
Elm
101
star
7

icalendar

🗓️ A small library for reading and writing ICalendar files.
Elixir
94
star
8

yesql

An Elixir library for using SQL.
Elixir
76
star
9

purescript-aws-lambda-express

PureScript
22
star
10

wisp

Gleam
20
star
11

sqlight

💡 Use SQLite from Gleam!
Gleam
19
star
12

clint

🏚️ Nothing to see here.
Elixir
19
star
13

learning

Elixir
16
star
14

total

Basic exhaustiveness checking of unions in Elixir
Elixir
15
star
15

puter

Setting up a computer is annoying so let's automate it.
Ruby
14
star
16

soup

A simple interpreted language written in Elixir
Elixir
14
star
17

plug-redirect

A plug builder for redirecting requests.
Elixir
13
star
18

temporary-env

A tool for managing application environment state within tests.
Elixir
11
star
19

gleeunit

Gleam bindings for the Erlang EUnit test framework
Erlang
11
star
20

gleam-cloudflare-worker

JavaScript
10
star
21

nerf

Gleam bindings to gun, the Erlang HTTP/1.1, HTTP/2 and Websocket client
Gleam
9
star
22

generative-elm

Exploring Matt Pearson's "Generative Art" book, with Elm!
Elm
9
star
23

exercism

Because problems are fun.
Elixir
9
star
24

erlcaml

Erlang
8
star
25

gleam_sendgrid

A client for the SendGrid transactional email API
Gleam
8
star
26

tetromino

A little game of Tetris!
Rust
7
star
27

ecoji

Base64 is so 1999, isn't there something better?
Rust
6
star
28

linux-audio-interface-compatibility

6
star
29

elm-hearts

Inspired by the 1998 intro of the Powerpuff Girls <3
Elm
6
star
30

action

Gleam
5
star
31

lpil

Code monkey monorepo trinkets
Elixir
5
star
32

glance

Gleam
5
star
33

latex-templates

Because words are hard, and MS Word is terrible
TeX
4
star
34

elixir-aws-lambda

JavaScript
4
star
35

advent-of-code

Rust
4
star
36

dotfiles

Magic!
Shell
4
star
37

epgsql

Rust
4
star
38

htmb

Gleam
4
star
39

decksterity

A thingy for DJ me
Rust
4
star
40

gh-counts

How many Gleam projects are there?
Erlang
4
star
41

antigone

Argon2 password hashing for Gleam.
Gleam
4
star
42

cymbal

Build YAML in Gleam!
Gleam
4
star
43

purescript-format

Haskell
3
star
44

serverless-static-site

JavaScript
3
star
45

beam-lisp

Erlang
3
star
46

talk-slides

https://lpil.github.io/talk-slides/
HTML
3
star
47

osc

Because I want to learn about OSC and handling binaries in Elixir.
Elixir
3
star
48

stepper

A little JS step sequencer
JavaScript
3
star
49

formal

Gleam
3
star
50

justin

Gleam
3
star
51

exception

Gleam
2
star
52

llvm

Louis' Little Virtual Machine
Rust
2
star
53

phoenix-webpack-example

CSS
2
star
54

rust-stepper

Rust
2
star
55

kent-erlang-mooc

Erlang
2
star
56

kalimba-tabs

Elm
2
star
57

crisp

A Rusty Lisp
Rust
2
star
58

archive

Elixir
2
star
59

99-bottles-of-oop

Ruby
2
star
60

logging

Erlang
2
star
61

glue

🩹 Generate functions from your Gleam code!
Gleam
2
star
62

xcss-crystal

Abandoned, see the README
Crystal
2
star
63

zeptomail

A client for the Zeptomail transactional email API
Gleam
2
star
64

life

Conway's game of life in various languages.
Rust
2
star
65

palette

A useless library that does stuff the standard library does better.
Elixir
2
star
66

gleam-elixir-london-preview

Rust
1
star
67

waive-website

HTML
1
star
68

ka-li-da-scope

JavaScript
1
star
69

joy

Gleam
1
star
70

reddit-css

Stylesheets for various subreddits -
CSS
1
star
71

roman-numerals

Convert numbers to Roman numerals and back.
Elixir
1
star
72

gleam-test-ci-project

Erlang
1
star
73

nice-button

JavaScript
1
star
74

i3-conf

My 'puter. Tiling is fun.
Perl
1
star
75

lans-syn

Because the ANS synth is cool.
Clojure
1
star
76

natter

Elixir
1
star
77

photobank

An app for sharing photos!
Elixir
1
star
78

pushover-error-logger

An Erlang/OTP logger handler that sends error logs to Pushover
Erlang
1
star
79

elm-against-humanity

https://lpil.uk/elm-against-humanity
Elm
1
star
80

a-blog

CSS
1
star
81

learn-you-some-elixir

CSS
1
star
82

find_my_primes

Elixir
1
star
83

jot

Gleam
1
star
84

access

Clojure
1
star
85

openbox-conf

My openbox desktop config
Shell
1
star
86

my-first-code

HTML
1
star
87

purescript-datastore

PureScript
1
star
88

elixir-jot

Slightly more fun than HTML
Elixir
1
star
89

beecrypt

🐝 Buzzing Gleam bindings to the Erlang bcrypt hashing library
Gleam
1
star
90

vim2hs-flexible

Vim Script
1
star
91

prismic_ecto

An Ecto adapter for the Prismic.io CMS
Elixir
1
star
92

ex-unit-pride

Run your tests with pride.
Elixir
1
star
93

javascript-dom-parser

Gleam
1
star
94

spinner

Gleam
1
star
95

cheep

Because graphical programming is no fun.
Ruby
1
star
96

phoenix_guides

User guides for the Phoenix web development framework.
CSS
1
star
97

envoy

📂 A zero dependency cross platform Gleam package for reading environment variables
Gleam
1
star
98

cgi

Gleam
1
star
99

youid

Gleam
1
star