idnits 2.17.1 draft-boronine-teleport-03.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 == Line 190 has weird spacing: '... Schema t("...' == Line 194 has weird spacing: '...Decimal t("D...' == Line 198 has weird spacing: '...Integer t("I...' == Line 201 has weird spacing: '... String t("...' == Line 204 has weird spacing: '...Boolean t("B...' == (1 more instance...) == The document doesn't use any RFC 2119 keywords, yet seems to have RFC 2119 boilerplate text. -- The document date (September 27, 2015) is 3134 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 (~~), 8 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 September 27, 2015 4 Intended status: Informational 5 Expires: March 30, 2016 7 Minimal JSON Type System 8 draft-boronine-teleport-03 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 and provides two 14 patterns for extending it with new 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 for 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 March 30, 2016. 41 Copyright Notice 43 Copyright (c) 2015 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 . . . . . . . . . . . . . . . . . . . . . 6 69 9. Security Considerations . . . . . . . . . . . . . . . . . . . 6 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 made possible by the 141 fact that type definitions are JSON values. The Schema type is 142 useful to specify APIs. For example, to describe a function you can 143 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 This document does not give a full definition of the t function, it 165 merely provides some instances of its inputs and outputs. Expanding 166 the definition of the t function is the basis for extending Teleport. 168 5.1. Concrete Types 170 x is of concrete type c if and only if 172 1. c is a string 174 2. x :: t(c). 176 5.2. Generic Types 178 x is of generic type g if and only if 180 1. g is a string 182 2. x :: t({g: p}) for some p 184 6. Built-in Concrete Types 186 JSON t("JSON") is the set of all JSON values. This type can be 187 used as a wildcard for type-checking or as a noop for 188 composable serialization. 190 Schema t("Schema") is the set of all type definitions, including 191 all strings representing concrete types as well as every 192 instance of every generic type. 194 Decimal t("Decimal") is the set of all numbers. This type 195 represents real numbers and arbitrary-precision 196 approximations of real numbers. 198 Integer t("Integer") is the set of all numbers that don't have a 199 fractional or exponent part. 201 String t("String") is the set of all strings. Note that JSON 202 strings are sequences of Unicode characters. 204 Boolean t("Boolean") is a set containing the JSON values true and 205 false. 207 DateTime t("DateTime") is the set of all strings that are valid 208 according to RFC 3339 [RFC3339]. This type represents 209 typestamps with optional timezone data. 211 7. Built-in Generic Types 213 x :: t({"Array": p}) if and only if 215 x is an array 217 e :: t(p) for every element e in x 219 x :: t({"Map": p}) if and only if 221 x is an object 223 v :: t(p) for every pair (k, v) in x 225 x :: t({"Struct": p}) if and only if 227 p is an object. If p has the key "required", p.required must be 228 an object, similarly if p has the key "optional", p.optional must 229 be an object. If p has both, the names in these two objects must 230 be disjoint, that is, they cannot have a pair of members with the 231 same name. 233 x is an object. The name of every member of p.required is also 234 the name of a member of x. 236 For every pair (k, v) in x, there is a pair (k, s) in either 237 p.required or p.optional such that v :: t(s). 239 NOTE: the definition of Struct implies that its parameter p can 240 contain arbitrary metadata in the form of other object members. 242 8. IANA Considerations 244 This memo includes no request to IANA. 246 9. Security Considerations 248 All drafts are required to have a security considerations section. 249 See RFC 3552 [RFC3552] for a guide. 251 10. References 253 10.1. Normative References 255 [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate 256 Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/ 257 RFC2119, March 1997, 258 . 260 [RFC3339] Klyne, G. and C. Newman, "Date and Time on the Internet: 261 Timestamps", RFC 3339, DOI 10.17487/RFC3339, July 2002, 262 . 264 [RFC4627] Crockford, D., "The application/json Media Type for 265 JavaScript Object Notation (JSON)", RFC 4627, DOI 266 10.17487/RFC4627, July 2006, 267 . 269 10.2. Informative References 271 [RFC3552] Rescorla, E. and B. Korver, "Guidelines for Writing RFC 272 Text on Security Considerations", BCP 72, RFC 3552, DOI 273 10.17487/RFC3552, July 2003, 274 . 276 Appendix A. Mailing List 278 Comments are solicited and should be addressed to the working group's 279 mailing list at teleport-json@googlegroups.com and/or the author. 281 Author's Address 283 Alexei Boronine (editor) 285 Email: alexei@boronine.com