On Friday, 14 June 2013 at 12:31, Slava Yurin wrote:
See https://github.com/iskra/jsonx. Maybe it decoder/encoder will help you.14.06.2013, 17:13, "Steve Strong" <st...@srstrong.com>:
,_______________________________________________
erlang-questions mailing list
erlang-q...@erlang.org
http://erlang.org/mailman/listinfo/erlang-questions
On Friday, 14 June 2013 at 14:06, Thomas Allen wrote:
Hi Steve,I've done some similar things, except rather than using a parsetransform to do this (I do not like parse transforms except as a lastresort, I find macros a more explicit way to express compile-timethings) I simply store my record info in application env when myapplication starts, and define functions that access these values:db:fields(RecName), etc. Then, I have higher level functions that usethis metadata. It's easy to test, and I reason it's pretty fast, withapplication env being backed by ETS (it's never been a bottleneck).%% in .hrl-define(DB_FIELDS(Model), {Model, record_info(fields, Model)}).%% in app:start/0:application:set_env(db, model_fields,[?DB_FIELDS(blog_post),?DB_FIELDS(contact_message)]),%% in record utilsfields() ->{ok, Fields} = application:get_env(db, model_fields),Fields.fields(Model) ->proplists:get_value(Model, fields()).%% etc.Maybe others here with more experience can correct me, but I think someErlang developers are too eager to introduce parse transforms to solvesimple problems.Thomas
On Fri, Jun 14, 2013, at 03:34 AM, Steve Strong wrote:
My plan for the actual JSON encode / decode is for the mapper to producea structure that's compatible with jsx(https://github.com/talentdeficit/jsx) - that's the encoder / decoderthat we currently use. If we go the open-source route, I'd probably aimto make that pluggable so that folk can use their preferred JSON encoder.Cheers,Steve--Steve Strong
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)
On Friday, 14 June 2013 at 12:31, Slava Yurin wrote:
See https://github.com/iskra/jsonx. Maybe it decoder/encoder will help you.
14.06.2013, 17:13, "Steve Strong" <st...@srstrong.com (mailto:st...@srstrong.com)>:
Sent with Sparrow (http://www.sparrowmailapp.com/?sig)
,_______________________________________________erlang-questions mailing list
There's another approach.
Define your own "record" language,
and generate the Erlang code (*including* -record declarations) from that.
And if you go down that route, be sure to first checkout the Piqi project at :http://piqi.org