Arrays and JSON
Calendar output
Calendar::toArray() returns snake_case calendar metadata plus events, todos, journals, and warnings. Events, todos, and journals include their applicable public fields, recurrence data, organizers, attendees, and repeated values; events and todos also include alarms. Date-times and intervals are converted to strings; missing values remain null, and repeated values remain lists.
$payload = $calendar->toArray();
$json = $calendar->toJson(JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE);jsonSerialize() returns the same data as toArray(). toJson(int $options = 0) accepts normal PHP json_encode() options and throws JsonException if conversion fails.
One generic property
Property::toArray() returns the same property shape used by complete component output:
[
'name' => 'X-MY-FIELD',
'type' => 'text',
'value' => 'example',
'values' => ['example'],
'parameters' => ['X-SOURCE' => 'manual'],
'raw_value' => 'example',
]Complete component output
Calendar::toComponentArray() recursively returns each component's name, properties, and components. It preserves repeated, unknown, vendor, and non-event data.
Calling occurrencesBetween() does not add an occurrences key to Calendar array or JSON output. Use the returned Event collection directly when you need expanded instances.
Use toArray() for convenient Calendar, Event, Todo, and Journal data. Use toComponentArray() when the complete component tree matters. Neither recreates the original .ics bytes: line folding, casing, newline style, and byte formatting are not retained.