Lua
Lua
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 Lua Downloads
local chilkat = require("chilkat")
-- 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"
-- }
-- ]
-- }
local json = chilkat.JsonObject.new()
json:update_string("kind", "calendar#event")
json:update_string("etag", "some_etag")
json:update_string("id", "string value")
json:update_string("status", "string value")
json:update_string("htmlLink", "string value")
json:update_string("created", "datetime value")
json:update_string("updated", "datetime value")
json:update_string("summary", "string value")
json:update_string("description", "string value")
json:update_string("location", "string value")
json:update_string("colorId", "string value")
json:update_string("creator.id", "string value")
json:update_string("creator.email", "string value")
json:update_string("creator.displayName", "string value")
json:update_bool("creator.self", true)
json:update_string("organizer.id", "string value")
json:update_string("organizer.email", "string value")
json:update_string("organizer.displayName", "string value")
json:update_bool("organizer.self", true)
json:update_string("start.date", "date value")
json:update_string("start.dateTime", "datetime value")
json:update_string("start.timeZone", "string value")
json:update_string("end.date", "date value")
json:update_string("end.dateTime", "datetime value")
json:update_string("end.timeZone", "string value")
json:update_bool("endTimeUnspecified", true)
json:update_string("recurrence[0]", "string value")
json:update_string("recurringEventId", "string value")
json:update_string("originalStartTime.date", "date value")
json:update_string("originalStartTime.dateTime", "datetime value")
json:update_string("originalStartTime.timeZone", "string value")
json:update_string("transparency", "string value")
json:update_string("visibility", "string value")
json:update_string("iCalUID", "string value")
json:update_number("sequence", "1234")
json:update_string("attendees[0].id", "string value")
json:update_string("attendees[0].email", "string value")
json:update_string("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:update_bool("attendees[i].organizer", true)
json:update_bool("attendees[i].self", true)
json:update_bool("attendees[i].resource", true)
json:update_bool("attendees[i].optional", true)
json:update_string("attendees[i].responseStatus", "string value")
json:update_string("attendees[i].comment", "string value")
json:update_number("attendees[i].additionalGuests", "1234")
json.i = 1
json:update_string("attendees[i].id", "string value")
json:update_string("attendees[i].email", "string value")
json:update_string("attendees[i].displayName", "string value")
json:update_bool("attendees[1].organizer", true)
json:update_bool("attendees[1].self", true)
json:update_bool("attendees[1].resource", true)
json:update_bool("attendees[1].optional", true)
json:update_string("attendees[1].responseStatus", "string value")
json:update_string("attendees[1].comment", "string value")
json:update_number("attendees[1].additionalGuests", "1234")
json:update_bool("attendeesOmitted", true)
json:update_string("extendedProperties.private.someKey", "string value")
json:update_string("extendedProperties.shared.someKey", "string value")
json:update_string("hangoutLink", "string value")
json:update_string("gadget.type", "string value")
json:update_string("gadget.title", "string value")
json:update_string("gadget.link", "string value")
json:update_string("gadget.iconLink", "string value")
json:update_number("gadget.width", "1234")
json:update_number("gadget.height", "1234")
json:update_string("gadget.display", "string value")
json:update_string("gadget.preferences.someKey", "string value")
json:update_bool("anyoneCanAddSelf", true)
json:update_bool("guestsCanInviteOthers", true)
json:update_bool("guestsCanModify", true)
json:update_bool("guestsCanSeeOtherGuests", true)
json:update_bool("privateCopy", true)
json:update_bool("locked", true)
json:update_bool("reminders.useDefault", true)
json:update_string("reminders.overrides[0].method", "string value")
json:update_number("reminders.overrides[0].minutes", "1234")
json:update_string("source.url", "string value")
json:update_string("source.title", "string value")
json:update_string("attachments[0].fileUrl", "string value")
json:update_string("attachments[0].title", "string value")
json:update_string("attachments[0].mimeType", "string value")
json:update_string("attachments[0].iconLink", "string value")
json:update_string("attachments[0].fileId", "string value")
json:update_string("attachments[1].fileUrl", "string value")
json:update_string("attachments[1].title", "string value")
json:update_string("attachments[1].mimeType", "string value")
json:update_string("attachments[1].iconLink", "string value")
json:update_string("attachments[1].fileId", "string value")
json.emit_compact = false
print(json:emit())