idnits 2.17.1 draft-boronine-teleport-01.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- No issues found here. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year == The document doesn't use any RFC 2119 keywords, yet seems to have RFC 2119 boilerplate text. -- The document date (December 2, 2014) is 3434 days in the past. Is this intentional? Checking references for intended status: Informational ---------------------------------------------------------------------------- ** Obsolete normative reference: RFC 4627 (Obsoleted by RFC 7158, RFC 7159) Summary: 1 error (**), 0 flaws (~~), 2 warnings (==), 1 comment (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Internet Engineering Task Force A. Boronine, Ed. 3 Internet-Draft 4 Intended status: Informational December 2, 2014 5 Expires: June 5, 2015 7 Minimal JSON Type System 8 draft-boronine-teleport-01 10 Abstract 12 Teleport is a minimal type system designed as an extension of JSON. 13 It comes with 10 types sufficient for basic use, but it defines a 14 pattern for extending it with arbitrary types. Teleport's type 15 definitions are JSON values, for example, an array of strings is 16 defined as {"Array": "String"}. 18 Teleport implementations can be used for data serialization, input 19 validation, for documenting JSON APIs and for building API clients. 21 This document provides the mathematical basis of Teleport and can be 22 used for implementing libraries. 24 Status of This Memo 26 This Internet-Draft is submitted in full conformance with the 27 provisions of BCP 78 and BCP 79. 29 Internet-Drafts are working documents of the Internet Engineering 30 Task Force (IETF). Note that other groups may also distribute 31 working documents as Internet-Drafts. The list of current Internet- 32 Drafts is at http://datatracker.ietf.org/drafts/current/. 34 Internet-Drafts are draft documents valid for a maximum of six months 35 and may be updated, replaced, or obsoleted by other documents at any 36 time. It is inappropriate to use Internet-Drafts as reference 37 material or to cite them other than as "work in progress." 39 This Internet-Draft will expire on June 5, 2015. 41 Copyright Notice 43 Copyright (c) 2014 IETF Trust and the persons identified as the 44 document authors. All rights reserved. 46 This document is subject to BCP 78 and the IETF Trust's Legal 47 Provisions Relating to IETF Documents 48 (http://trustee.ietf.org/license-info) in effect on the date of 49 publication of this document. Please review these documents 50 carefully, as they describe your rights and restrictions with respect 51 to this document. Code Components extracted from this document must 52 include Simplified BSD License text as described in Section 4.e of 53 the Trust Legal Provisions and are provided without warranty as 54 described in the Simplified BSD License. 56 Table of Contents 58 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 59 2. Conventions and Terminology . . . . . . . . . . . . . . . . . 3 60 2.1. Syntax . . . . . . . . . . . . . . . . . . . . . . . . . 3 61 3. Type Patterns . . . . . . . . . . . . . . . . . . . . . . . . 3 62 4. JSON Schemas . . . . . . . . . . . . . . . . . . . . . . . . 3 63 5. Mathematical Basis . . . . . . . . . . . . . . . . . . . . . 4 64 5.1. Concrete Types . . . . . . . . . . . . . . . . . . . . . 4 65 5.2. Generic Types . . . . . . . . . . . . . . . . . . . . . . 4 66 6. Built-in Concrete Types . . . . . . . . . . . . . . . . . . . 4 67 7. Built-in Generic Types . . . . . . . . . . . . . . . . . . . 5 68 8. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 5 69 9. Security Considerations . . . . . . . . . . . . . . . . . . . 5 70 10. References . . . . . . . . . . . . . . . . . . . . . . . . . 6 71 10.1. Normative References . . . . . . . . . . . . . . . . . . 6 72 10.2. Informative References . . . . . . . . . . . . . . . . . 6 73 Appendix A. Mailing List . . . . . . . . . . . . . . . . . . . . 6 74 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 6 76 1. Introduction 78 In Teleport, a type is a relation between a type definition and a 79 value space. For example: 81 t("Integer") = {0, -1, 1, -2, 2, -3, 3, ...} 83 Here "Integer" is a type definition and t("Integer") is the set of 84 all values this type can take. The t function is used to represent 85 this relationship. 87 Because Teleport is based on JSON, all value spaces are sets of JSON 88 values. More interestingly, type definitions are JSON values too, 89 which makes it trivial to share them with other programs. 91 Teleport's design goals is to be a natural extension of JSON, be 92 extremely lightweight, and extendable not only with rich types but 93 with high-level type system concepts. 95 2. Conventions and Terminology 97 The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", 98 "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this 99 document are to be interpreted as described in RFC 2119 [RFC2119]. 101 The terms "JSON", "JSON text", "JSON value", "member", "element", 102 "object", "array", "number", "string", "boolean", "true", "false", 103 and "null" in this document are to be interpreted as defined in RFC 104 4627 [RFC4627]. 106 2.1. Syntax 108 Throughout this document, an extended JSON syntax is used. Unquoted 109 strings are symbols representing JSON values, sets and functions. 110 Also, the following set theory syntax is used: 112 a :: A Set A contains element a. 114 D -> C The set of functions that map values from set D to values 115 from set C. 117 3. Type Patterns 119 Types defined simply by a string, like "Integer" above, are called 120 concrete. Teleport ships with 7 concrete types. 122 A generic type maps a set of schemas to a set of value spaces. Each 123 pair in the mapping is called an instance. For example, {"Array": 124 "Integer"} is an instance of the Array type. 126 Three generic types are provided: Array, Map and Struct. Their 127 precise definition is provided in the following sections, but these 128 examples should be enough to understand how they work: 130 ["foo", "bar"] :: t({"Array": "String"}) 132 {"a": 1, "b": 2} :: t({"Map": "Integer"}) 134 {"name": "Alexei"} :: t({"Struct": { 135 "required": {"name": "String"}, 136 "optional": {"age": "Integer"}}) 138 4. JSON Schemas 140 "Schema", one of the build-in concrete types, is defined as the set 141 of all known type definitions. This is made possible by the fact 142 that type definitions are JSON values. The Schema type is useful to 143 specify APIs. For example, to describe a function you can use this: 145 t({"Struct": { 146 "optional": {}, 147 "required": { 148 "input": "Schema", 149 "output": "Schema"}}} 151 5. Mathematical Basis 153 The set of all JSON values is called V. A subset of V is called a 154 value space and the set of all value spaces is called S. 156 V = {null, true, false, 0, 1, 2, 3, 4, ...} 158 S = {{}, {null}, {null, true}, {null, ...}, ...} 160 There is a certain function t that maps JSON values to value spaces. 162 t :: (V -> S) 164 5.1. Concrete Types 166 x is of concrete type c if and only if 168 1. c is a string 170 2. x :: t(c). 172 5.2. Generic Types 174 x is of generic type g if and only if 176 1. g is a string 178 2. x :: t({g: p}) for some p 180 6. Built-in Concrete Types 182 t("JSON") The set of all JSON values. 184 t("Schema") The set of all type definitions, including all 185 strings representing concrete types as well as every 186 instance of every generic type. 188 t("Integer") All numbers that don't have a fractional or exponent 189 part. 191 t("Float") All numbers that have a fractional or exponent part. 193 t("String") All strings. 195 t("Boolean") All booleans. 197 t("DateTime") All strings that are valid according to ISO 8601 198 [ISO.8601.1988]. 200 7. Built-in Generic Types 202 x :: t({"Array": p}) if and only if 204 x is an array 206 e :: t(p) for every element e in x 208 x :: t({"Map": p}) if and only if 210 x is an object 212 v :: t(p) for every pair (k, v) in x 214 x :: t({"Struct": p}) if and only if 216 p is an object with at least two members: required and optional. 217 Both are objects and their names are disjoint, that is, they don't 218 have a pair of members with the same name. 220 x is an object. The name of every member of p.required is also 221 the name of a member of x. 223 For every pair (k, v) in x, there is a pair (k, s) in either 224 p.required or p.optional such that v :: t(s). 226 Note: the definition of Struct implies that its parameter p can 227 contain arbitrary metadata in the form of other object members. 229 8. IANA Considerations 231 This memo includes no request to IANA. 233 9. Security Considerations 235 All drafts are required to have a security considerations section. 236 See RFC 3552 [RFC3552] for a guide. 238 10. References 240 10.1. Normative References 242 [ISO.8601.1988] 243 International Organization for Standardization, "Data 244 elements and interchange formats - Information interchange 245 - Representation of dates and times", ISO Standard 8601, 246 June 1988. 248 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 249 Requirement Levels", BCP 14, RFC 2119, March 1997. 251 [RFC4627] Crockford, D., "The application/json Media Type for 252 JavaScript Object Notation (JSON)", RFC 4627, July 2006. 254 10.2. Informative References 256 [RFC3552] Rescorla, E. and B. Korver, "Guidelines for Writing RFC 257 Text on Security Considerations", BCP 72, RFC 3552, July 258 2003. 260 Appendix A. Mailing List 262 Comments are solicited and should be addressed to the working group's 263 mailing list at teleport-json@googlegroups.com and/or the author. 265 Author's Address 267 Alexei Boronine (editor) 269 Email: alexei@boronine.com