View Source parthenon

Build Status Coverage Hex Pm Docs Erlang Versions

parthenon is an OTP application that parses AWS Athena structures into Erlang terms.

usage

Usage

Inside rebar.config:

%% ...
{deps, [
    %% ...
    parthenon
]}.

Inside .app.src:

%% ...
{applications, [
    %% ...
    parthenon
]},
%% ...

Inside the code:

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:

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

Development

running-all-the-tests-and-linters

Running all the tests and linters

You can run all the tests and linters with the rebar3 alias:

rebar3 check