Created
October 10, 2009 12:13
-
-
Save sinkovsky/206809 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
tick_list_from_json(Series_id, Json) -> | |
try mochijson2:decode(Json) of | |
List when is_list(List) -> | |
[ json_struct_to_tick(Series_Id, P) || P <- List ]; | |
Struct when is_tuple(Struct) -> | |
[ json_struct_to_tick(Series_Id, Struct) ] | |
catch | |
_Any -> | |
{error, bad_json} | |
end. | |
json_struct_to_tick(Series_id, {struct, Struct}) -> | |
#tick{ | |
id = {Series_id, proplists:get_value(<<"timestamp">>, Struct)}, | |
value = proplists:get_value(<<"value">>, Struct) | |
}. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment