Network Working Group | P. Kewisch |
Internet-Draft | Mozilla |
Intended status: Standards Track | June 23, 2016 |
Expires: December 25, 2016 |
jCard: The JSON format for vCard
draft-ietf-jcardcal-jcard-00
This specification defines "jCard", a JSON format for vCard data.
This Internet-Draft is submitted in full conformance with the provisions of BCP 78 and BCP 79.
Internet-Drafts are working documents of the Internet Engineering Task Force (IETF). Note that other groups may also distribute working documents as Internet-Drafts. The list of current Internet-Drafts is at http://datatracker.ietf.org/drafts/current/.
Internet-Drafts are draft documents valid for a maximum of six months and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use Internet-Drafts as reference material or to cite them other than as "work in progress."
This Internet-Draft will expire on December 25, 2016.
Copyright (c) 2016 IETF Trust and the persons identified as the document authors. All rights reserved.
This document is subject to BCP 78 and the IETF Trust's Legal Provisions Relating to IETF Documents (http://trustee.ietf.org/license-info) in effect on the date of publication of this document. Please review these documents carefully, as they describe your rights and restrictions with respect to this document. Code Components extracted from this document must include Simplified BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Simplified BSD License.
The vCard data format [RFC6350] has gone through multiple revisions, most recently vCard 4. The goal followed by this format is the capture and exchange of information normally stored within an address book or directory application. As certain similarities to the iCalendar data format [RFC5545] exist it makes sense to define a JSON-based data format for vCards that is similar to the jCal format defined in [I-D.ietf-jcardcal-jcal].
The purpose of this specification is to define "jCard", a JSON format for vCard data. One main advantage to using a JSON-based format as defined in [RFC4627] over the classic vCard format is easier processing for JavaScript based widgets and libraries, especially in the scope of web-based applications.
The key design considerations are essentially the same as those for [I-D.ietf-jcardcal-jcal] and [RFC6321], that is:
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in [RFC2119].
The underlying format used for jCard is JSON. Consequently, the terms "object" and "array" as well as the four primitive types are to be interpreted as described in Section 1 of [RFC4627].
Some examples in this document contain "partial" JSON documents used for illustrative purposes. In these examples, three periods "..." are used to indicate a portion of the document that has been removed for compactness.
This section describes how vCard data is converted to jCard using a simple mapping between the vCard data model and JSON elements.
vCard uses a line folding mechanism to limit lines of data to a maximum line length (typically 72 characters) to ensure maximum likelihood of preserving data integrity as it is transported via various means (e.g., email) - see Section 3.2 of [RFC6350]. Prior to converting vCard data into jCard all folded lines MUST be unfolded.
vCard data uses an "escape" character sequence for text values and property parameter values. When such text elements are converted into jCard the escaping MUST be removed. See Section 3.4 of [RFC6350].
One key difference in the formatting of values used in vCard and jCard is that in jCard the specification uses date/time values aligned with the complete representation, extended format of [ISO.8601.2004].
In certain cases it makes sense to group a sequence of vcard objects into a stream of objects. While the vCard 4 standard doesn't define a stream of vcard objects, having one makes it easier to identify multiple jCard objects and also ensures compatibility to jCal. A jCard stream is identified by an array, where the first element is the string "vcardstream". Subsequent elements are vCard objects represented as described in this document.
In the typical case where there is only one vCard object, encapsulation inside a "vcardstream" array MAY be omitted.
A vCard stream can contain one or more vCard objects. Each vCard object, delimited by "BEGIN:VCARD" and "END:VCARD", is represented in JSON as a fixed length array with two elements:
The representation of a vCard object in JSON will be named "vcard component" throughout this document.
Example:
["vcardstream", ["vcard", [ /* properties */ ] ], ["vcard", [ /* properties */ ] ], ... ]
vCard objects are comprised of a set of "properties", "parameters" and "values". The top level of a vCard object contains "properties". A "property" has a "value" and a set of zero or more "parameters". vCard objects are delimited by the general properties "BEGIN" and "END" with the fixed value "VCARD" as defined in Section 6.1.1 and 6.1.2 of [RFC6350]. In addition, the vCard format is versioned, therefore the "version" property is mandatory. To comply with Section 6.7.9 of [RFC6350], the value of the version property MUST be "4.0".
Each individual vCard property is represented in jCard by an array with three fixed elements, followed by one or more additional elements, depending on if the property is a multi-value property as described in Section 3.3 of [RFC6350].
The array consists of the following fixed elements: Section 3.3.1.1 there can be any number of additional elements.
The remaining elements of the array are used for the value of the property. For single-value properties, the array MUST have exactly four elements, for multi-valued properties as described in
The array describing the property can then be inserted into the array designated for properties in the "vcard" component.
Example:
["vcard", [ ["version", {}, "text", "4.0"], ["fn", {}, "text", "John Doe"], ["gender", {}, "text", "M"], ... ], ]
The property parameters in the second element of the property array associate a set of parameter names with their respective value. Parameters are further described in Section 3.4.
To allow for a cleaner implementation, the parameter object MUST be present even if there are no parameters. In this case, an empty object MUST be used.
This section describes some properties that have special handling when converting to jCard.
Various vCard properties defined in [RFC6350], for example the "CATEGORIES" property, are defined as multi-valued properties. In jCal these properties are added as further members of the array describing the property.
Note that additional multi-valued properties may be added in extensions to the iCalendar format.
Example:
["vcard", [ ["categories", {}, "text", "computers", "cameras"], ... ], ... ]
[RFC6350] Section 3.3 defines a grouping construct that is used to group related properties together. In jCard, each grouped property appears as a separate property containing the group name and property name, separated by a "." character. This was done to maintain compatibilty of array elements with [I-D.ietf-jcardcal-jcal].
Example:
["vcard", [ ["groupname.email", {}, "text", "johndoe@example.org"], ... ], ... ]
Property parameters are represented as a JSON object where each key-value pair represents the vCard parameter name and its value. The name of the parameter MUST be in lowercase, the original case of the parameter value MUST be preserved. For example, the "LANG" property parameter is represented in jCard by the "lang" key. Any new vCard parameters added in the future will be converted in the same way.
Example:
["vcard", [ ["role", { "lang": "tr" }, "text", "roca"], ... ], ... ]
vCard defines a "VALUE" property parameter (Section 5.2 of [RFC6350]). This property parameter MUST NOT be added to the parameters object. Instead, the value type is always explicitly mentioned in the third element of the array describing the property. Thus, when converting from vCard to jCard, any "VALUE" property parameters are skipped. When converting from jCard into vCard, the appropriate "VALUE" property parameter MUST be included in the vCard property if the value type is not the default value type for that property.
In [RFC6350], some parameters allow using a COMMA-separated list of values. To ease processing in jCard, the value to such parameters MUST be represented in an array containing the separated values. The array elements MUST be string values. Single-value parameters SHOULD be represented using a single string value, but an array with one element MAY also be used. An example for a such parameter is the vCard "SORT-AS" parameter, more such parameters may be added in extensions.
DQUOTE characters used to encapsulate the separated values MUST NOT be added to the jCard parameter value.
Example 1:
["vcard", [ ["n", { "sort-as": ["Harten", "Rene"] }, "text", "van der Harten;Rene,J.;Sir;R.D.O.N." ], ["fn", {}, "text", "Rene van der Harten"] ... ], ... ]
The type of a vCard value is explicitly mentioned in the third element of the array describing a jCard property. The actual values of the property can be found in the fourth and following elements of the array.
... ["kind", {}, "text", "group"], ...
... ["source", {}, "uri", "ldap://ldap.example.com/cn=babs%20jensen"], ...
date-complete = year "-" month "-" day ;YYYY-MM-DD date-noreduc = date-complete / "--" month "-" day; --MM-DD / "---" day; ---DDD date = date-noreduc / year; YYYY / year "-" month ; YYYY-MM / "--" month; --MM
... ["bday", {}, "date", "1985-04-12"], ["bday", {}, "date", "1985-04"], ["bday", {}, "date", "1985"], ["bday", {}, "date", "--0412"], ["bday", {}, "date", "---12"], ...
time-notrunc = hour [":" minute [":" second]] [zone] time = time-notrunc / "-" minute ":" second [zone]; -mm:ss / "-" minute [zone]; -mm / "--" second [zone]; --ss
... ["x-time-local", {}, "time", "12:30:00"], ["x-time-utc", {}, "time", "12:30:00Z"], ["x-time-offset", "time", "12:30:00-0800"], ["x-time-reduced", "time", "23"], ["x-time-truncated", "time", "-30"], ...
... ["anniversary", {}, "date-time", "2013-02-14T12:30:00"], ["anniversary", {}, "date-time", "2013-01-10T19:00:00Z"], ["anniversary", {}, "date-time", "2013-08-15T09:45:00+0100"], ["anniversary", {}, "date-time", "---15T09:45:00+0100"], ...
... ["x-non-smoking", {}, "boolean", true], ...
... ["x-karma-points", {}, "integer", 42], ...
... ["x-grade", {}, "float", 1.3], ...
... // Note: [RFC6350] mentions use of utc-offset // for the TZ property as NOT RECOMMENDED ["tz", {}, "utc-offset", "-05:00"], ..
... ["lang", {}, "language-tag", "de"], ..
vCard extension properties and property parameters (those with an "X-" prefix in their name) are handled in the same way as other properties and property parameters: the property is represented by an array, the property parameter represented by an object. The property or parameter name uses the same name as for the vCard extension, but in lowercase. For example, the "X-FOO" property in vCard turns into the "x-foo" jCard property. See Section 5 for how to deal with default values for unrecognized extension properties or property parameters.
When converting property and property parameter values, the names SHOULD be converted to uppercase. Although vCard names are case insensitive, common practice is to keep them all uppercase following the actual definitions in [RFC6350].
Backslash escaping and line folding MUST be applied to the resulting vCard data as required by [RFC6350].
When converting to vCard, the VALUE parameter MUST be added to properties whose default value type is unknown. The VALUE parameter SHOULD NOT be added to properties using the default value type.
In vCard, properties have a default value type specified by their definition, e.g. "BDAY"'s value type is "date-and-or-time", but it can also be reset to a single "text" value. When a property uses its default value type, the "VALUE" property parameter does not need to be specified on the property.
When new properties are defined or "X-" properties used, a vCard to jCard converter might not recognize them, and not know what the appropriate default value types are, yet they need to be able to preserve the values. A similar issue arises for unrecognized property parameters. As a result, the following rules are applied when dealing with unrecognized properties and property parameters:
Example: The following is an example of an unrecognized vCard property (that uses an "URI" value as its default), and the equivalent jCard representation of that property.
vCard:
X-COMPLAINT-URI:mailto:abuse@example.org
jCard:
... ["x-complaint-uri", {}, "text", "mailto:abuse@example.org"], ...
Example: The following is an example of a jCard property (where the corresponding vCard property uses a "INTEGER" value as its default), and the equivalent vCard representation of that property. It is assumed that the parser has knowledge of the default data type for the "x-karma-points" property.
jCard:
... ["x-karma-points", {}, "integer", 95], ...
vCard:
X-KARMA-POINTS:95
Example: The following is an example of an unrecognized vCard property parameter (that uses a "FLOAT" value as its default) specified on a recognized vCard property, and the equivalent jCard representation of that property and property parameter.
vCard:
GENDER;X-PROBABILITY=0.8:M
jCard:
... ["gender", { "x-probability": "0.8" }, "text", "M"], ...
[RFC6350] defines the data types DATE, DATE-TIME, TIME, DATE-AND-OR-TIME and TIMESTAMP, covering various aspects of dates and times. As jCard is more "strongly typed", some of these types have been consolidated. This section aims to aid conversion between jCard and vCard and vice versa.
Regardless of the date/time related property converted, jCard and vCard use different representations of the [ISO.8601.2004] format. The date format MUST be adjusted during conversion.
For security considerations specific to calendar data, see Section 9 of [RFC6350]. Since this specification is a mapping from vCard, no new security concerns are introduced related to calendar data.
The use of JSON as a format does have security risks. Section 7 of [RFC4627] discusses these risks.
This document defines a MIME media type for use with vCard in JSON data. This media type SHOULD be used for the transfer of calendaring data in JSON.
The author would like to thank the following for their valuable contributions: Cyrus Daboo, Mike Douglass, William Gill, Erwin Rehme, and Dave Thewlis. This specification originated from the work of the XML-JSON technical committee of the Calendaring and Scheduling Consortium.
[calconnect-artifacts] | The Calendaring and Scheduling Consortium, "Code Artifacts and Schemas" |
[RFC4627] | Crockford, D., "The application/json Media Type for JavaScript Object Notation (JSON)", RFC 4627, DOI 10.17487/RFC4627, July 2006. |
Below is an ABNF schema as per [RFC5234] for vCard in JSON. ABNF Symbols not described here are taken from [RFC4627]. The schema is non-normative and given for reference only.
The numeric section numbers given in the comments refer to section in [RFC6350]. Additional semantic restrictions apply, especially regarding the allowed properties and sub-components per component. Details on these restrictions can be found in this document and [RFC6350].
Additional schemas may be available on the internet at [calconnect-artifacts].
; A vCard Stream is an array with the first element being the ; string "vcardstream". All remaining elements are jcardobjects. jcardstream = begin-array DQUOTE "vcardstream" DQUOTE *(value-separator jcardobject) end-array jcardobject = component ; A jCard object consists of the name string "vcard" and a properties ; array. Restrictions to which properties and may be specified are to ; be taken from RFC6350. jcardobject = begin-array DQUOTE component-name DQUOTE value-separator properties-array end-array ; A jCard property consists of the name string, parameters object, ; type string and one or more values as specified in this document. property = begin-array DQUOTE property-name DQUOTE value-separator params-object value-separator DQUOTE type-name DQUOTE propery-value *(value-separator property-value) end-array properties-array = begin-array [ property *(value-separator property) ] end-array ; Property values depend on the type-name. Aside from the value types ; mentioned here, extensions may make use of other JSON value types. property-value = string / number / boolean ; The jCard params-object is a JSON object which follows the semantic ; guidelines described in this document. params-object = begin-object [ params-member *(value-separator params-member) ] end-object params-member = DQUOTE param-name DQUOTE name-separator param-value param-value = string ; The type MUST be a valid type as described by this document. New ; value types can be added by extensions. type-name = "text" / "uri" / "date" / "time" / "date-time" / "boolean" / "integer" / "float" / "utc-offset" / "language-tag" / x-type ; Property, parameter and type names MUST be lowercase. Additional ; semantic restrictions apply as described by this document and ; RFC6350. component-name = lowercase-name property-name = lowercase-name param-name = lowercase-name x-type = lowercase-name lowercase-name = 1*(%x61-7A / DIGIT / "-")
This section contains an example of a vCard object with its jCard representation.
BEGIN:VCARD VERSION:4.0 FN:Simon Perreault N:Perreault;Simon;;;ing. jr,M.Sc. BDAY:--0203 ANNIVERSARY:20090808T1430-0500 GENDER:M LANG;PREF=1:fr LANG;PREF=2:en ORG;TYPE=work:Viagenie ADR;TYPE=work:;Suite D2-630;2875 Laurier; Quebec;QC;G1V 2M2;Canada TEL;VALUE=uri;TYPE="work,voice";PREF=1:tel:+1-418-656-9254;ext=102 TEL;VALUE=uri;TYPE="work,cell,voice,video,text":tel:+1-418-262-6501 EMAIL;TYPE=work:simon.perreault@viagenie.ca GEO;TYPE=work:geo:46.772673,-71.282945 KEY;TYPE=work;VALUE=uri: http://www.viagenie.ca/simon.perreault/simon.asc TZ:-0500 URL;TYPE=home:http://nomis80.org END:VCARD
["vcard", [ ["version", {}, "text", "4.0"], ["fn", {}, "text", "Simon Perreault"], ["n", {}, "text", "Perreault;Simon;;;ing. jr,M.Sc."], ["bday", {}, "date", "--02-03"], ["anniversary", {}, "date-time", "2009-08-08T14:30:00-0500"], ["gender", {}, "text", "M"], ["lang", { "pref": "1" }, "language-tag", "fr"], ["lang", { "pref": "2" }, "language-tag", "en"], ["org", { "type": "work" }, "text", "Viagenie"], ["adr", { "type": "work" }, "text", ";Suite D2-630;2875 Laurier;Quebec;QC;G1V 2M2;Canada" ], ["tel", { "type": ["work", "voice"], "pref": "1" }, "uri", "tel:+1-418-656-9254;ext=102" ], ["tel", { "type": ["work", "cell", "voice", "video", "text"] }, "uri", "tel:+1-418-262-6501" ], ["email", { "type": "work" }, "text", "simon.perreault@viagenie.ca" ], ["geo", { "type": "work" }, "uri", "geo:46.772673,-71.282945"], ["key", { "type": "work" }, "uri", "http://www.viagenie.ca/simon.perreault/simon.asc" ], ["tz", {}, "utc-offset", "-05:00"], ["url", { "type": "home" }, "uri", "http://nomis80.org"] ] ]
Also, there should be a mention of how multi-values inside a structured value should be handled. With the second approach, these could themselves be an array, similar to how this document currently defines multi-value parameters.