1
0
Fork
You've already forked josh
0
Pure Gleam JSON library
  • Gleam 100%
2026年06月14日 21:08:29 -07:00
LICENSES init 2026年06月02日 12:02:27 -07:00
src more get examples 2026年06月03日 12:23:04 -07:00
test more get examples 2026年06月03日 12:23:04 -07:00
.gitignore init 2026年06月02日 12:02:27 -07:00
gleam.toml don't include gleam_json as release dep 2026年06月14日 21:07:38 -07:00
manifest.toml deps update 2026年06月14日 21:08:29 -07:00
README.md fix readme example 2026年06月09日 10:33:37 -07:00
REUSE.toml init 2026年06月02日 12:02:27 -07:00

josh

Package Version Hex Docs License MIT

Pure Gleam JSON Library

gleam add josh
importjoshimportgleam/dictpubfnmain()->Nil{assertjosh.parse("{\"Hello\": \"World!\"}")==Ok(josh.Object(dict.from_list(#("Hello",josh.String("World!")))))assertjosh.to_string(josh.Array([josh.String("Foo"),josh.String("bar")]))=="[\"foo\",\"bar\"]"}

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

Comparison with gleam_json

Most uses cases should use gleam_json, as it will be much faster. The only case were this library is preferred is when one would like to parse the JSON itself into a Gleam type, instead of just its contents.

Tips

Converting to gleam_json

importgleam/dictimportgleam/jsonimportgleam/listimportjoshfnjosh_to_gleam_json(json:josh.Json)->json.Json{casejson{josh.Null->json.null()josh.Bool(bool)->json.bool(bool)josh.Integer(int)->json.int(int)josh.Float(float)->json.float(float)josh.String(string)->json.string(string)josh.Array(array)->json.array(array,josh_to_gleam_json)josh.Object(object)->object|>dict.to_list|>list.map(fn(item){#(item.0,josh_to_json(item.1))})|>json.object}}

Development

gleam test # Run the tests

Licensing

This project follows the REUSE 3.3 spec. All gleam files and gleam.toml are licensed under MIT.