We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
We do have a ADT - Erlang record
-record(adt, {id, title, ...}).
external serialization works with maps
jsx:encode(#{<<"id">> => ..., <<"title">> => ...})
How to automate process of ADT to maps and back transformation
-ifndef(decode). -define(decode(Type, Struct), list_to_tuple([Type | [lens:get(lens:at(typecast:s(X)), Struct) || X <- record_info(fields, Type)]] ) ). -endif. -ifndef(encode). -define(encode(Type, Struct), maps:from_list( [{typecast:s(Key), Value} || {Key, Value} <- lists:zip( record_info(fields, Type), tl(tuple_to_list(Struct)) ), Value /= undefined, Value /= null ] ) ). -endif.
The text was updated successfully, but these errors were encountered:
No branches or pull requests
We do have a ADT - Erlang record
external serialization works with maps
How to automate process of ADT to maps and back transformation
The text was updated successfully, but these errors were encountered: