• Stars
    star
    130
  • Rank 277,575 (Top 6 %)
  • Language
    Erlang
  • License
    Other
  • Created almost 5 years ago
  • Updated over 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

pgo

๐Ÿ˜ Use PostgreSQL databases with PGO
Gleam
42
star
10

purescript-aws-lambda-express

PureScript
22
star
11

wisp

Gleam
20
star
12

sqlight

๐Ÿ’ก Use SQLite from Gleam!
Gleam
19
star
13

clint

๐Ÿš๏ธ Nothing to see here.
Elixir
19
star
14

learning

Elixir
16
star
15

total

Basic exhaustiveness checking of unions in Elixir
Elixir
15
star
16

puter

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

soup

A simple interpreted language written in Elixir
Elixir
14
star
18

plug-redirect

A plug builder for redirecting requests.
Elixir
13
star
19

temporary-env

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

gleeunit

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

gleam-cloudflare-worker

JavaScript
10
star
22

nerf

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

generative-elm

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

exercism

Because problems are fun.
Elixir
9
star
25

erlcaml

Erlang
8
star
26

gleam_sendgrid

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

tetromino

A little game of Tetris!
Rust
7
star
28

decode

Ergonomic dynamic decoders for Gleam!
Gleam
7
star
29

ecoji

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

linux-audio-interface-compatibility

6
star
31

elm-hearts

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

action

Gleam
5
star
33

lpil

Code monkey monorepo trinkets
Elixir
5
star
34

glance

Gleam
5
star
35

latex-templates

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

elixir-aws-lambda

JavaScript
4
star
37

advent-of-code

Rust
4
star
38

dotfiles

Magic!
Shell
4
star
39

epgsql

Rust
4
star
40

htmb

Gleam
4
star
41

decksterity

A thingy for DJ me
Rust
4
star
42

gh-counts

How many Gleam projects are there?
Erlang
4
star
43

antigone

Argon2 password hashing for Gleam.
Gleam
4
star
44

cymbal

Build YAML in Gleam!
Gleam
4
star
45

purescript-format

Haskell
3
star
46

serverless-static-site

JavaScript
3
star
47

beam-lisp

Erlang
3
star
48

talk-slides

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

osc

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

stepper

A little JS step sequencer
JavaScript
3
star
51

json-typedef

Work with JSON using a schema!
Gleam
3
star
52

formal

Gleam
3
star
53

xmb

A tiny XML builder for Gleam
Gleam
3
star
54

justin

Gleam
3
star
55

exception

Gleam
2
star
56

llvm

Louis' Little Virtual Machine
Rust
2
star
57

phoenix-webpack-example

CSS
2
star
58

rust-stepper

Rust
2
star
59

kent-erlang-mooc

Erlang
2
star
60

kalimba-tabs

Elm
2
star
61

crisp

A Rusty Lisp
Rust
2
star
62

archive

Elixir
2
star
63

99-bottles-of-oop

Ruby
2
star
64

logging

Erlang
2
star
65

glue

๐Ÿฉน Generate functions from your Gleam code!
Gleam
2
star
66

xcss-crystal

Abandoned, see the README
Crystal
2
star
67

zeptomail

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

life

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

gpxb

Gleam
2
star
70

palette

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

gleam-elixir-london-preview

Rust
1
star
72

waive-website

HTML
1
star
73

ka-li-da-scope

JavaScript
1
star
74

joy

Gleam
1
star
75

atomic-array

Atomic mutable int arrays for Gleam!
Gleam
1
star
76

reddit-css

Stylesheets for various subreddits -
CSS
1
star
77

gleam-test-ci-project

Erlang
1
star
78

nice-button

JavaScript
1
star
79

i3-conf

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

lans-syn

Because the ANS synth is cool.
Clojure
1
star
81

natter

Elixir
1
star
82

photobank

An app for sharing photos!
Elixir
1
star
83

pushover-error-logger

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

elm-against-humanity

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

a-blog

CSS
1
star
86

learn-you-some-elixir

CSS
1
star
87

find_my_primes

Elixir
1
star
88

jot

Gleam
1
star
89

roman-numerals

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

access

Clojure
1
star
91

openbox-conf

My openbox desktop config
Shell
1
star
92

purescript-datastore

PureScript
1
star
93

node-socket-client

Gleam
1
star
94

queryb

A very limited RDMS query builder library
Gleam
1
star
95

my-first-code

HTML
1
star
96

beecrypt

๐Ÿ Buzzing Gleam bindings to the Erlang bcrypt hashing library
Gleam
1
star
97

elixir-jot

Slightly more fun than HTML
Elixir
1
star
98

vim2hs-flexible

Vim Script
1
star
99

prismic_ecto

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

ex-unit-pride

Run your tests with pride.
Elixir
1
star