# julienne
[](https://hex.pm/packages/julienne)
[](https://hexdocs.pm/julienne/)
A JSON parser that produces a flat representation of the decoded JSON.
Decoded vales are a list of terms with depth information, rather than nested data structures.
This approach is required when working in an environment that doesn't support recursive data structures.
## Usage
```sh
gleam add julienne@1
```
```gleam
import julienne
pub fn main() {
let assert Ok(tokens) = julienne.parse("true")
// Returns: [#(Boolean(True), 0)]
let assert Ok(tokens) = julienne.parse("null")
// Returns: [#(Null, 0)]
let assert Ok(tokens) = julienne.parse("\"hello\"")
// Returns: [#(String("hello"), 0)]
let assert Ok(tokens) = julienne.parse("123")
// Returns: [#(Integer(123), 0)]
let assert Ok(tokens) = julienne.parse("1.5e10")
// Returns: [#(Number(Positive, 1, #(5, 1), 10), 0)]
let assert Ok(tokens) = julienne.parse("[true, false, null]")
// Returns: [
// #(Array, 0),
// #(Boolean(True), 1),
// #(Boolean(False), 1),
// #(Null, 1)
// ]
let assert Ok(tokens) = julienne.parse("{\"a\": true, \"b\": false}")
// Returns: [
// #(Object, 0),
// #(Field("a"), 1),
// #(Boolean(True), 1),
// #(Field("b"), 1),
// #(Boolean(False), 1)
// ]
let assert Ok(tokens) = julienne.parse("{\"a\": {\"b\": false, \"c\": {}}}")
// Returns: [
// #(Object, 0),
// #(Field("a"), 1),
// #(Object, 1),
// #(Field("b"), 2),
// #(Boolean(False), 2),
// #(Field("c"), 2),
// #(Object, 2)
// ]
}
```
## How It Works
The parser converts JSON into a flat list of `Term` values, where each term includes:
- The token type (Boolean, Null, String, Integer, Number, Array, Object, or Field)
- The depth level (0 for root, 1 for first level of nesting, etc.)
## Development
```sh
gleam run # Run the project
gleam test # Run the tests
```
Further documentation can be found at <https://hexdocs.pm/julienne>.
## Credit
Created for [EYG](https://eyg.run), a new integration focused programming language.