Intermediate
Real-world programs often exchange data as JSON and work with dates and times. Phograph provides built-in nodes for both.
The json-parse node takes a JSON string and produces a Phograph
value — a number, string, list, or dictionary depending on the content.
The json-encode node does the reverse: it takes any Phograph value
and produces a JSON string.
constant '{"name":"Ada","age":36}' --> json-parse --> get "name" --> log
outputs: "Ada"
dict ["x", 10, "y", 20] --> json-encode --> log
outputs: '{"x":10,"y":20}'
You can chain the two nodes to verify that encoding and parsing are inverses:
value --> json-encode --> json-parse --> equal? --> log
\---------------------------------------/ outputs: true
Phograph includes several date and time nodes:
date-now — returns the current date and time.date-create — builds a date from year, month, day, hour, minute, second.date-components — extracts year, month, day, etc. from a date.date-add — adds a duration to a date.date-diff — returns the difference between two dates. date-create(2026, 3, 5, 9, 0, 0) --> date-add(hours 2) --> date-components
outputs: hour = 11
Duration values are created with helper nodes that convert human-friendly units into an internal duration type:
seconds 90 -- 90 seconds
minutes 5 -- 5 minutes (300 seconds)
hours 2 -- 2 hours
days 7 -- 7 days
These plug directly into date-add and can be compared with
date-diff results.
date-now --> date-add(days 30) --> log -- prints a date 30 days from now
json-parse converts a JSON string into a Phograph value.json-encode converts a Phograph value back to a JSON string.date-now, date-create, date-components,
date-add, date-diff) let you construct, inspect, and manipulate dates.seconds, minutes, hours,
days) create duration values for arithmetic on dates.