# parthenon
[](https://github.com/AntoineGagne/parthenon/actions)
[](https://coveralls.io/r/AntoineGagne/parthenon?branch=master)
[](https://hex.pm/packages/parthenon)
[](https://hexdocs.pm/parthenon)
[](http://www.erlang.org)
`parthenon` is an OTP application that parses AWS Athena structures into Erlang terms.
## Usage
Inside `rebar.config`:
```erl
%% ...
{deps, [
%% ...
parthenon
]}.
```
Inside ``.app.src``:
```erl
%% ...
{applications, [
%% ...
parthenon
]},
%% ...
```
Inside the code:
```erl
ok = parthenon:add_schema(athena_structure, <<"struct<a: int, b: int>">>).
{ok, #{a := 123, b := 456}} = parthenon:decode(athena_structure, <<"{a=123, b=456}">>, [
{object_format, maps}, {key_format, existing_atom}
]).
```
To test it out from the shell, it is possible to simply do:
```erl
application:ensure_all_started(parthenon).
ok = parthenon:add_schema(athena_structure, <<"struct<a: int, b: int>">>).
{ok, #{a := 123, b := 456} = Response} = parthenon:decode(athena_structure, <<"{a=123, b=456}">>, [
{object_format, maps}, {key_format, existing_atom}
]).
ok = parthenon:add_schema(nested_structures, <<"struct<a: int, b: array<struct<c: int, d: string>>>">>).
{ok, #{a := 123, b := [#{c := 456, d := <<"Some test, some test">>}]} = Response2} = parthenon:decode(
nested_structures, <<"{a=123, b=[{c=456, d=Some test, some test}]}">>, [
{object_format, maps}, {key_format, existing_atom}
]
).
%% If `jiffy' is present
<<"{\"b\":456,\"a\":123}">> = jiffy:encode(Response).
<<"{\"b\":[{\"d\":\"Some test, some test\",\"c\":456}],\"a\":123}">> = jiffy:encode(Response2).
```
## Development
### Running all the tests and linters
You can run all the tests and linters with the ``rebar3`` alias:
```sh
rebar3 check
```