Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/antoinegagne/parthenon
A library to parse Athena structures into Erlang terms
https://github.com/antoinegagne/parthenon
athena aws aws-athena erlang erlang-library hex parser
Last synced: about 2 months ago
JSON representation
A library to parse Athena structures into Erlang terms
- Host: GitHub
- URL: https://github.com/antoinegagne/parthenon
- Owner: AntoineGagne
- License: other
- Created: 2022-07-20T20:03:21.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2024-07-18T16:06:28.000Z (5 months ago)
- Last Synced: 2024-10-24T23:29:31.467Z (about 2 months ago)
- Topics: athena, aws, aws-athena, erlang, erlang-library, hex, parser
- Language: Erlang
- Homepage:
- Size: 52.7 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# parthenon
[![Build Status](https://github.com/AntoineGagne/parthenon/actions/workflows/erlang.yml/badge.svg)](https://github.com/AntoineGagne/parthenon/actions)
[![Coverage](https://coveralls.io/repos/AntoineGagne/parthenon/badge.png?branch=master)](https://coveralls.io/r/AntoineGagne/parthenon?branch=master)
[![Hex Pm](http://img.shields.io/hexpm/v/parthenon.svg?style=flat)](https://hex.pm/packages/parthenon)
[![Docs](https://img.shields.io/badge/hex-docs-green.svg?style=flat)](https://hexdocs.pm/parthenon)
[![Erlang Versions](https://img.shields.io/badge/Supported%20Erlang%2FOTP-21%20to%2027-blue)](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">>).
{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">>).
{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>>">>).
{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
```