garret-smith / aeon Goto Github PK
View Code? Open in Web Editor NEWAnother Erlang to Object Notation translator
License: BSD 3-Clause "New" or "Revised" License
Another Erlang to Object Notation translator
License: BSD 3-Clause "New" or "Revised" License
When trying to implement aeon in OTP19, I am not getting any record specification:
** exception error: {no_type,{test,{record,user}}}
in function aeon_common:field_types/2 (/home/hazims/src/garret_aeon/_build/default/lib/aeon/src/aeon_common.erl, line 27)
in call from aeon_to_jsx:record_to_jsx/2 (/home/hazims/src/garret_aeon/_build/default/lib/aeon/src/aeon_to_jsx.erl, line 11)
in call from test2:test/0 (/home/hazims/src/garret_aeon/_build/default/lib/aeon/src/test2.erl, line 23)
If I try to get the record types defined in the test module:
7> test:'#types'().
[{{type,privilege},
{union,[{atom,login},
{atom,create},
{atom,delete},
{atom,grant}]}}]
The code is:
test1.erl
-module(test).
-compile({parse_transform, runtime_types}).
-compile({parse_transform, exprecs}).
-type privilege() :: login | create | delete | grant.
-record(user, {
name :: binary(),
age :: integer(),
height :: float(),
birthday :: {Year :: integer(),
Month :: integer(),
Day :: integer()},
privileges :: [privilege()]
}).
-export_type([privilege/0]).
-export_records([user]).
It seems that some of the available record information is not available in OTP19.
Might have something to do with changes in erl_syntax_lib since R16.
//Hazim
I am trying to compile the test provided in README and getting "undefined parse transform 'runtime_types'" compile time error. What am I missing?
-module(aeon_test).
-compile({parse_transform, runtime_types}).
-compile({parse_transform, exprecs}).
-type privilege() :: login | create | delete | grant.
-record(user, {
name :: binary(),
age :: integer(),
height :: float(),
birthday :: {Year :: integer(),
Month :: integer(),
Day :: integer()},
privileges :: [privilege()]
}).
-export_type([privilege/0]).
-export_records([user]).
User = #user{
name = <<"Garret Smith">>,
age = 34,
height = 6.0,
birthday = {1982, 06, 29},
privileges = [login, create, delete, grant]
},
Json = jsx:encode(aeon:record_to_jsx(User, test)),
io:fwrite("~s~n", [Json]),
User1 = aeon:to_record(jsx:decode(Json), test, user).
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.