Hi, I appreciate the contributions, however to simplify the merging, I'd like to see these given as github pull requests, or at least as .patch files. Any chance you could do that?
-Jesse On Thu, May 15, 2014 at 7:05 PM, can2nac <[email protected]> wrote: > Hi, > > ChicagoBoss-0.8.7, > don't know how to define nested objects in CB, so i use prolists for this > purpose. Unfort. if you return json with record where one of the fields is > proplist cb crashes due to is_list() and following list_to_binary(Val) what > is not quite correct. > So i made changes in boss_model_manager_boss_db.erl (attached) to solve > this, works fine for me. > Also i have made changes in date/time formatting as 1) lists are no good for > json, they are converted to Arrays, binary is much better 2) it is better to > pass date/time in universal format "cO" and make formatting on client side > with JS > > to_json(Object) -> > Data = lists:map (fun > ({Attr, Val}) when is_list (Val) -> > %{Attr, list_to_binary (Val)}; %original, removed by can2nac, 15-05-14 > {Attr, case is_proplist(Val) of true -> Val; false -> list_to_binary (Val) > end}; %added by can2nac, 15-05-14 > ({Attr, {_,_,_} = Val}) -> > %%list_to_binary was added and format was changed > {Attr, list_to_binary (erlydtl_filters:date (calendar:now_to_datetime > (Val), "cO"))}; %added by can2nac, 15-05-14 > %{Attr, erlydtl_filters:date (calendar:now_to_datetime (Val), "F d, Y > H:i:s")}; %original, removed by can2nac, 15-05-14 > ({Attr, {{_, _, _}, {_, _, _}} = Val}) -> > %%format was changed > {Attr, list_to_binary (erlydtl_filters:date (Val, "cO"))}; %added by > can2nac, 15-05-14 > %{Attr, list_to_binary (erlydtl_filters:date (Val, "F d, Y H:i:s"))}; > %original, removed by can2nac, 15-05-14 > (Other) -> > Other > end, Object:attributes()), > {struct, Data}. > > %%added by can2nac, 05-15-14, taken from > %https://code.google.com/p/zotonic/source/browse/src/support/z_utils.erl?r=d9da1b9de75c2567aca49a22548e05c89808d94a > %with 2 additinal lines according to spec. "whose first elements are keys > atoms, which work as shorthand for tuples {Atom, true}", > http://www.erlang.org/doc/man/proplists.html > is_proplist([]) -> true; > is_proplist([{K,_}|R]) when is_atom(K) -> is_proplist(R); > is_proplist([A|R]) when is_atom(A) -> is_proplist(R); %added by can2nac, > 15-05-14 > is_proplist([A]) when is_atom(A) -> true; %added by can2nac, 15-05-14 > is_proplist(_) -> false. > > No heavy testing was performed, use on your own risk > > -- > You received this message because you are subscribed to the Google Groups > "ChicagoBoss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > Visit this group at http://groups.google.com/group/chicagoboss. > To view this discussion on the web visit > https://groups.google.com/d/msgid/chicagoboss/2ff4ee02-4443-41b4-a337-98beba7e0607%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- Jesse Gumm Owner, Sigma Star Systems 414.940.4866 || sigma-star.com || @jessegumm -- You received this message because you are subscribed to the Google Groups "ChicagoBoss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. Visit this group at http://groups.google.com/group/chicagoboss. To view this discussion on the web visit https://groups.google.com/d/msgid/chicagoboss/CAPTXyXfRqRTjhinvyw83FgTHP%3D83fQwer_DfLwN8hqNwiBqauA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
