Cocktail v0.4.0 Cocktail.Parser.JSON View Source
Create schedules from JSON strings or maps.
WIP: this module doesn’t currently support the :count
option, nor does it
support recurrence times or exception times. Also, there’s no associated
builder yet to actually generate output that this parser would parse.
TODO: write long description
Link to this section Summary
Functions
Parses a string of JSON into a Cocktail.Schedule.t/0
Parses JSON-like map into a Cocktail.Schedule.t/0
Link to this section Functions
Link to this function
parse(json_string)
View Source
parse(String.t) :: {:ok, Cocktail.Schedule.t} | {:error, term}
Parses a string of JSON into a Cocktail.Schedule.t/0
.
Examples
iex> {:ok, schedule} = parse("{\"start_time\":\"2017-01-01 09:00:00\",\"recurrence_rules\":[{\"frequency\":\"daily\",\"interval\":2}]}")
...> schedule
#Cocktail.Schedule<Every 2 days>
Link to this function
parse_map(map)
View Source
parse_map(map) :: {:ok, Cocktail.Schedule.t} | {:error, term}
Parses JSON-like map into a Cocktail.Schedule.t/0
.
Examples
iex> {:ok, schedule} = parse_map(%{"start_time"=>"2017-01-01 09:00:00","recurrence_rules"=>[%{"frequency"=>"daily","interval"=>2}]})
...> schedule
#Cocktail.Schedule<Every 2 days>