Dart
Dart
Google Calendar -- Generate Event JSON
See more Google Calendar Examples
Demonstrates how to generate the JSON for an event resource. This code can be used as a template for generating JSON to insert new events.See https://developers.google.com/google-apps/calendar/v3/reference/events#resource for details about the Calender Event Resource JSON.
Chilkat Dart Downloads
import 'package:chilkat/chilkat.dart';
void main() {
// This example (below) generates the following JSON:
// Note: Your application code would construct the event JSON using your
// desired subset of members. For boolean values, you would pass true or false.
// For date or date/time values, you would pass the appropriately formatted date/time string.
// {
// "kind": "calendar#event",
// "etag": "some_etag",
// "id": "string value",
// "status": "string value",
// "htmlLink": "string value",
// "created": "datetime value",
// "updated": "datetime value",
// "summary": "string value",
// "description": "string value",
// "location": "string value",
// "colorId": "string value",
// "creator": {
// "id": "string value",
// "email": "string value",
// "displayName": "string value",
// "self": true
// },
// "organizer": {
// "id": "string value",
// "email": "string value",
// "displayName": "string value",
// "self": true
// },
// "start": {
// "date": "date value",
// "dateTime": "datetime value",
// "timeZone": "string value"
// },
// "end": {
// "date": "date value",
// "dateTime": "datetime value",
// "timeZone": "string value"
// },
// "endTimeUnspecified": true,
// "recurrence": [
// "string value"
// ],
// "recurringEventId": "string value",
// "originalStartTime": {
// "date": "date value",
// "dateTime": "datetime value",
// "timeZone": "string value"
// },
// "transparency": "string value",
// "visibility": "string value",
// "iCalUID": "string value",
// "sequence": 1234,
// "attendees": [
// {
// "id": "string value",
// "email": "string value",
// "displayName": "string value",
// "organizer": true,
// "self": true,
// "resource": true,
// "optional": true,
// "responseStatus": "string value",
// "comment": "string value",
// "additionalGuests": 1234
// },
// {
// "id": "string value",
// "email": "string value",
// "displayName": "string value",
// "organizer": true,
// "self": true,
// "resource": true,
// "optional": true,
// "responseStatus": "string value",
// "comment": "string value",
// "additionalGuests": 1234
// }
// ],
// "attendeesOmitted": true,
// "extendedProperties": {
// "private": {
// "someKey": "string value"
// },
// "shared": {
// "someKey": "string value"
// }
// },
// "hangoutLink": "string value",
// "gadget": {
// "type": "string value",
// "title": "string value",
// "link": "string value",
// "iconLink": "string value",
// "width": 1234,
// "height": 1234,
// "display": "string value",
// "preferences": {
// "someKey": "string value"
// }
// },
// "anyoneCanAddSelf": true,
// "guestsCanInviteOthers": true,
// "guestsCanModify": true,
// "guestsCanSeeOtherGuests": true,
// "privateCopy": true,
// "locked": true,
// "reminders": {
// "useDefault": true,
// "overrides": [
// {
// "method": "string value",
// "minutes": 1234
// }
// ]
// },
// "source": {
// "url": "string value",
// "title": "string value"
// },
// "attachments": [
// {
// "fileUrl": "string value",
// "title": "string value",
// "mimeType": "string value",
// "iconLink": "string value",
// "fileId": "string value"
// },
// {
// "fileUrl": "string value",
// "title": "string value",
// "mimeType": "string value",
// "iconLink": "string value",
// "fileId": "string value"
// }
// ]
// }
final json = CkJsonObject();
json.updateString('kind', 'calendar#event');
json.updateString('etag', 'some_etag');
json.updateString('id', 'string value');
json.updateString('status', 'string value');
json.updateString('htmlLink', 'string value');
json.updateString('created', 'datetime value');
json.updateString('updated', 'datetime value');
json.updateString('summary', 'string value');
json.updateString('description', 'string value');
json.updateString('location', 'string value');
json.updateString('colorId', 'string value');
json.updateString('creator.id', 'string value');
json.updateString('creator.email', 'string value');
json.updateString('creator.displayName', 'string value');
json.updateBool('creator.self', true);
json.updateString('organizer.id', 'string value');
json.updateString('organizer.email', 'string value');
json.updateString('organizer.displayName', 'string value');
json.updateBool('organizer.self', true);
json.updateString('start.date', 'date value');
json.updateString('start.dateTime', 'datetime value');
json.updateString('start.timeZone', 'string value');
json.updateString('end.date', 'date value');
json.updateString('end.dateTime', 'datetime value');
json.updateString('end.timeZone', 'string value');
json.updateBool('endTimeUnspecified', true);
json.updateString('recurrence[0]', 'string value');
json.updateString('recurringEventId', 'string value');
json.updateString('originalStartTime.date', 'date value');
json.updateString('originalStartTime.dateTime', 'datetime value');
json.updateString('originalStartTime.timeZone', 'string value');
json.updateString('transparency', 'string value');
json.updateString('visibility', 'string value');
json.updateString('iCalUID', 'string value');
json.updateNumber('sequence', '1234');
json.updateString('attendees[0].id', 'string value');
json.updateString('attendees[0].email', 'string value');
json.updateString('attendees[0].displayName', 'string value');
// Note: We could alternately specify an index using "i", which allows
// for an application to construct using a loop with a variable..
json.i = 0;
json.updateBool('attendees[i].organizer', true);
json.updateBool('attendees[i].self', true);
json.updateBool('attendees[i].resource', true);
json.updateBool('attendees[i].optional', true);
json.updateString('attendees[i].responseStatus', 'string value');
json.updateString('attendees[i].comment', 'string value');
json.updateNumber('attendees[i].additionalGuests', '1234');
json.i = 1;
json.updateString('attendees[i].id', 'string value');
json.updateString('attendees[i].email', 'string value');
json.updateString('attendees[i].displayName', 'string value');
json.updateBool('attendees[1].organizer', true);
json.updateBool('attendees[1].self', true);
json.updateBool('attendees[1].resource', true);
json.updateBool('attendees[1].optional', true);
json.updateString('attendees[1].responseStatus', 'string value');
json.updateString('attendees[1].comment', 'string value');
json.updateNumber('attendees[1].additionalGuests', '1234');
json.updateBool('attendeesOmitted', true);
json.updateString('extendedProperties.private.someKey', 'string value');
json.updateString('extendedProperties.shared.someKey', 'string value');
json.updateString('hangoutLink', 'string value');
json.updateString('gadget.type', 'string value');
json.updateString('gadget.title', 'string value');
json.updateString('gadget.link', 'string value');
json.updateString('gadget.iconLink', 'string value');
json.updateNumber('gadget.width', '1234');
json.updateNumber('gadget.height', '1234');
json.updateString('gadget.display', 'string value');
json.updateString('gadget.preferences.someKey', 'string value');
json.updateBool('anyoneCanAddSelf', true);
json.updateBool('guestsCanInviteOthers', true);
json.updateBool('guestsCanModify', true);
json.updateBool('guestsCanSeeOtherGuests', true);
json.updateBool('privateCopy', true);
json.updateBool('locked', true);
json.updateBool('reminders.useDefault', true);
json.updateString('reminders.overrides[0].method', 'string value');
json.updateNumber('reminders.overrides[0].minutes', '1234');
json.updateString('source.url', 'string value');
json.updateString('source.title', 'string value');
json.updateString('attachments[0].fileUrl', 'string value');
json.updateString('attachments[0].title', 'string value');
json.updateString('attachments[0].mimeType', 'string value');
json.updateString('attachments[0].iconLink', 'string value');
json.updateString('attachments[0].fileId', 'string value');
json.updateString('attachments[1].fileUrl', 'string value');
json.updateString('attachments[1].title', 'string value');
json.updateString('attachments[1].mimeType', 'string value');
json.updateString('attachments[1].iconLink', 'string value');
json.updateString('attachments[1].fileId', 'string value');
json.emitCompact = false;
print(json.emit());
}