Internet Engineering Task Force P. THOMY Internet-Draft Loco-labs Intended status: Informational 20 August 2023 Expires: 21 February 2024 JSON semantic format (JSON-NTV) draft-thomy-json-ntv-00 Abstract This document describes a set of simple rules for unambiguously and concisely encoding semantic data into JSON Data Interchange Format. These rules are based on an NTV (Named and Typed Values) data structure applicable to any simple or complex data. The JSON-NTV format is its JSON translation. Status of This Memo 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 https://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 21 February 2024. Copyright Notice Copyright (c) 2023 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 (https://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 Revised BSD License text as described in Section 4.e of the Trust Legal Provisions and are provided without warranty as described in the Revised BSD License. THOMY Expires 21 February 2024 [Page 1] Internet-Draft JSON semantic format (JSON-NTV) August 2023 Table of Contents 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2 1.1. Presentation . . . . . . . . . . . . . . . . . . . . . . 3 1.2. Key design features . . . . . . . . . . . . . . . . . . . 4 1.3. Requirements Language . . . . . . . . . . . . . . . . . . 5 2. NTV structure . . . . . . . . . . . . . . . . . . . . . . . . 6 2.1. NTV layers . . . . . . . . . . . . . . . . . . . . . . . 6 2.2. NTV entities . . . . . . . . . . . . . . . . . . . . . . 6 2.2.1. NTVsingle . . . . . . . . . . . . . . . . . . . . . . 7 2.2.2. NTVlist . . . . . . . . . . . . . . . . . . . . . . . 7 2.3. NTVtype and Namespace . . . . . . . . . . . . . . . . . . 8 2.3.1. Namespace . . . . . . . . . . . . . . . . . . . . . . 8 2.3.2. NTVtype . . . . . . . . . . . . . . . . . . . . . . . 8 3. JsonNTV . . . . . . . . . . . . . . . . . . . . . . . . . . . 10 3.1. JsonNTV format . . . . . . . . . . . . . . . . . . . . . 10 3.2. JsonNTVname . . . . . . . . . . . . . . . . . . . . . . . 11 3.3. JsonNTVtype . . . . . . . . . . . . . . . . . . . . . . . 12 3.4. JsonNTVvalue . . . . . . . . . . . . . . . . . . . . . . 13 4. Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 14 5. Parsing a JsonValue . . . . . . . . . . . . . . . . . . . . . 15 6. NTV extended structure . . . . . . . . . . . . . . . . . . . 17 7. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 17 8. Security Considerations . . . . . . . . . . . . . . . . . . . 18 9. References . . . . . . . . . . . . . . . . . . . . . . . . . 18 9.1. Normative References . . . . . . . . . . . . . . . . . . 18 9.2. Informative References . . . . . . . . . . . . . . . . . 18 Appendix A. Appendix 1 - Global NTVtype and Namespace . . . . . 19 A.1. Json . . . . . . . . . . . . . . . . . . . . . . . . . . 19 A.2. Numbers . . . . . . . . . . . . . . . . . . . . . . . . . 20 A.3. Datation . . . . . . . . . . . . . . . . . . . . . . . . 20 A.4. Period and Duration . . . . . . . . . . . . . . . . . . . 22 A.5. Location . . . . . . . . . . . . . . . . . . . . . . . . 22 A.6. Structured data . . . . . . . . . . . . . . . . . . . . . 23 A.7. Normalized String . . . . . . . . . . . . . . . . . . . . 24 A.8. Namespace . . . . . . . . . . . . . . . . . . . . . . . . 24 A.9. Custom NTVtype and Namespace . . . . . . . . . . . . . . 25 Appendix B. Appendix 2 - Complete ABNF notation . . . . . . . . 26 Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . 27 Contributors . . . . . . . . . . . . . . . . . . . . . . . . . . 27 Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 27 1. Introduction THOMY Expires 21 February 2024 [Page 2] Internet-Draft JSON semantic format (JSON-NTV) August 2023 1.1. Presentation The semantic level of JSON or CSV shared data remains low. It is often limited to the type of data defined in those exchange formats (strings for CSV formats; numbers, strings, arrays and objects for JSON formats). JSON-NTV proposes to increase the semantic level of the JSON entities [RFC8259] by adding two additional pieces of information to a JSON entity : * *name*: interpretation of the JSON value in human language or detailed information or link to external information, * *type*: interpretation of the JSON value in a data standard (eg. GeoJSON, datetime), in a data catalog or in a software language. The NTV entity is thus a triplet with a mandatory element (value) and two additional elements (name, type). _For example, Paris location can be represented by :_ - _a name : "paris",_ - _a type : geoJSON Point coordinates [RFC7946],_ - _a value : [2.3522, 48.8566]_ The easiest way to add that information into a JSON value is to use a JSON object with a single member. The first term is the additional elements using the syntax JSON-ND [JSON-ND]. The second term is the JSON value. _The JSON value of the previous example is:_ _{ "paris:point" : [2.3522, 48.8566] }_ With this approach, two NTV entities are defined : * *a primitive entity* which is not composed of any other entity, * *a structured entity* which is an ordered sequence of NTV entities. as well as two JSON formats depending on the presence of the additional elements : * *simple format* when name and type are not present * *named format* when name or type is present THOMY Expires 21 February 2024 [Page 3] Internet-Draft JSON semantic format (JSON-NTV) August 2023 _Example (entity composed of two other primitive entities):_ _{ "cities::point": [[2.3522, 48.8566], [4.8357, 45.7640]] } simple format for primitive entities_ _{"cities::point": {"paris":[2.3522, 48.8566], "lyon":[4.8357, 45.7640]}} named format for primitive entities_ A JSON-NTV generator produces a JSON value from a NTV entity and vice versa a JSON-NTV parser transforms a JSON value into a NTV entity. The conversion between NTV entity and native entity is outside the scope of this note. 1.2. Key design features The format is focused on simplicity, lightness and web usage. The key features of this format are the following: * *JSON as the base format* - JSON is simple and readable as simple text - JSON supports rich structure including nesting and basic types - JSON is web-native and very widely used and supported - JSON format has binary representation (eg. CBOR format) * *high semantic level of data* - wide variety of data typing - tree-like and customisable data typing * *compatibility with existing formats* - All JSON data is a JsonNTV data - All NTVtypes are standard types * *compatibility with any type of platform* - types and structures are independent of software and hardware platforms - the NTV concept is applicable to all types of "jsonable" data THOMY Expires 21 February 2024 [Page 4] Internet-Draft JSON semantic format (JSON-NTV) August 2023 * *reversibility* - the NTV entity coming from a JSON value is identical to the NTV entity from which the JSON value comes - the JSON representation of an NTV entity is the same as the JSON value used to construct the NTV entity * *tree structure* - all NTV entities are trees - tree properties are applicable to NTV entities 1.3. Requirements Language The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in BCP 14 [RFC2119] [RFC8174] when, and only when, they appear in all capitals, as shown here. This document also uses the following terms: *JsonType, JsonText, JsonName, JsonValue, JsonObject, JsonMember, JsonElement, JsonArray, JsonNumber, JsonString, JsonFalse, JsonNull, JsonTrue:* These terms are defined as type, text, name, value, object, member, element, array, number, string, false, null, true in the JSON grammar. *JsonPrimitive:* A JsonNumber, JsonString, JsonFalse, JsonTrue or JsonNull. *JsonUnnamed:* A JsonObject without a single member. *JsonNamed:* A JsonObject with a single member. *NTVsingle, NTVlist:* NTVlist and NTVsingle entities can be abbreviated as: * NVsingle : entity with default NTVtype "json", * NVlist : entity without NTVtype, * TVsingle, TVlist : entity without NTVname, THOMY Expires 21 February 2024 [Page 5] Internet-Draft JSON semantic format (JSON-NTV) August 2023 * Vsingle, Vlist : NVsingle or NVlist without NTVname. 2. NTV structure 2.1. NTV layers NTV and JsonNTV structures are defined as shown in Figure 1: * NTV is a data triplet (NTVname, NTVtype, NTVvalue) that contains all the information needed to build the native entity. * JsonNTV is the JsonValue of the NTV entity. JsonNTV is used to build an interchangeable JsonText +--------+ JSON load +-------+ NTV load +-------+ to_obj +------+ | |---------->| |--------->| NTV |--------->|native| |JsonText| |JsonNTV| |triplet| |entity| | |<----------| |<---------| |<---------| | +--------+ JSON dump +-------+ NTV dump +-------+ from_obj +------+ Figure 1: NTV layers _Example:_ * _Native layer_ new_year_2022 = datetime.date(2022, 01, 01) _is a Python variable "new_year_2022" corresponding to a datetime object_ * _NTV layer_ ("new_year_2022", "date", "2022-01-01") _is a triplet_ * _JsonNTV layer_ { "new_year_2022:date" : "2022-01-01" } _is a JsonValue_ * _JsonText layer_ '{"new_year_2022:date":"2022-01-01"}' _is a JsonString_ 2.2. NTV entities Two categories of entities (one primitive and one structured) are defined: * *NTVsingle* for the primitive entity, THOMY Expires 21 February 2024 [Page 6] Internet-Draft JSON semantic format (JSON-NTV) August 2023 * *NTVlist* for an ordered sequence of NTV entities An NTV entity is therefore a tree where the leaves nodes are the NTVsingle entities and where the inner nodes are the NTVlist entities 2.2.1. NTVsingle The data triplet of NTVsingle entities is composed by: * *NTVsingleValue*: This NTVvalue is the JSON representation (JsonValue) of the main content of the NTV entity, * *NTVsingleType*: This NTVtype defines the type of entity and the conversion rules between the native entity and the NTV entity. The default value is the "json" NTVtype. * *NTVname*: The NTVname is an additional textual information (JsonString) *In other words, any entity that has on the one hand a function of encoding it into a JsonValue and on the other hand a function of creating from a JsonValue can be taken into account. This approach is very general because the majority of computer objects are defined by a list of parameters (e.g. *args in python) and/or a list of key/ values (e.g. **kwargs in python) which simply translate into a JsonArray or a JsonObject.* The consistency between NTVsingleValue and NTVsingleType is outside the scope of this note. 2.2.2. NTVlist The data triplet of NTVlist entities is composed by: * *NTVlistValue*: This NTVvalue is an ordered sequence of included NTV entities. * *NTVlistType*: This NTVtype is a Namespace or a default NTVtype to apply to the NTV entities included. This NTVlistType avoids including a NTVtype (if default NTVtype) or reduces the length (if Namespace) in the JSON representation (JsonNTV) of the included NTV entities. The default value is "None". * *NTVname*: The NTVname is an additional textual information (JsonString) _Example of equivalent JSON representations:_ THOMY Expires 21 February 2024 [Page 7] Internet-Draft JSON semantic format (JSON-NTV) August 2023 _where NTVlistType is None for the global NTVlist_ _[ { ":point" : [2.3522, 48.8566]}, {":point" : [4.8357, 45.7640]} ]_ _where NTVlistType is "point" for the global NTVlist_ _{ "::point" : [ [2.3522, 48.8566], [4.8357, 45.7640] ] }_ _If JSON-value is { "::dat" : ["2022-01-28T18-23-54", {":point": [1.1, 2.2] ] } }, the parsers deduce that the first NTVvalue has a "dat" NTVtype and the second a "point" NTVtype._ 2.3. NTVtype and Namespace NTVtype is defined in a nested structure called Namespace: * A NTVtype is defined in a parent Namespace, * A Namespace is defined in a parent Namespace, This structuring of type makes it possible to reference any type of data that has a JSON representation and to consolidate all the shared data structures within the same tree of types. 2.3.1. Namespace A Namespace is included in a Namespace parent (NamespaceParent) and may contain Namespace childs. A Namespace is represented by a string followed by a point (NamespaceName). The global Namespace (root node in the Namespace tree) is represented by an empty string and its NamespaceParent is None. 2.3.2. NTVtype A NTVtype is defined by a name (NTVtypeName) and a Namespace parent (NamespaceParent). The NTVtype is unique in the Namespace parent. NTVtype and the rules to encode or decode NTVvalues MUST be understood by data producers and data consumers. So NTVtype and rules associated have to be defined in a specification shared by a large community. On the other hand, it must be possible for everyone to share data according to their own data structure. There are therefore two categories of NTVtype: THOMY Expires 21 February 2024 [Page 8] Internet-Draft JSON semantic format (JSON-NTV) August 2023 * custom NTVtype (and Namespace) which can be created by anyone without control, * shared NTVtype (and Namespace) that are defined in a single, shared repository. The corresponding rules are as follows: * NTVtype (or Namespace) whose name begins with '$' is of type 'custom' * NTVtype (or Namespace) included in a Namespace of type 'custom' is also of type 'custom' * Each 'shared' Namespace or NTVtype is uniquely managed. _Example:_ _If "fr." is a Namespace attached to the global Namespace and containing the Namespace 'BAN.' and the NTVtype 'dep', then:_ - _"fr.dep" is a shared NTVtype,_ - _"fr.$test" is a custom NTVtype,_ - _"fr.$example.one" is a custom NTVtype_ - _"fr.BAN.$test" is a custom NTVtype_ Three categories of NTVtype are defined (None, Simple, Generic). * The "None" NTVtype is used with NTVlist to indicate the absence of a default Type. * Simple NTVtype is associated to conversion rules between a native entity and a NTV entity. * Generic NTVtype is equivalent to a set of Simple NTVtype. This indicates that parsers use an associated simple NTVtype to decode the JsonNTVvalue. _Example:_ _"dat" is the generic NTVtype for "datetime" and "timeposix"_ _If a JSONvalue is { "::dat" : ["2022-01-28T18-23-54", 123456.78] }, the parser deduces that the first entity has a "datetime" NTVtype and the second a "timeposix" NTVtype._ THOMY Expires 21 February 2024 [Page 9] Internet-Draft JSON semantic format (JSON-NTV) August 2023 3. JsonNTV 3.1. JsonNTV format The JsonNTV format is the JsonValue representation of an NTV entity as defined in Figure 2, which uses ABNF from [RFC5234]. ; JSON representation of NTV entities (JsonNTV) JsonNTV = JsonNTVnamed / JsonNTVsimple JsonNTVnamed = beginObject JsonNTVMember endObject JsonNTVsimple = JsonNTVvalue JsonNTVMember = JsonNTVname nSep JsonNTVvalue ; Extract of JSON grammar used in this document beginArray = ws "[" ws beginObject = ws "{" ws endArray = ws "]" ws endObject = ws "}" ws nSep = ws ":" ws vSep = ws "," ws ws = *( %x20 / %x09 / %x0A / %x0D ) JsonValue = JsonValue ; indicates that rule is defined in RFC8259 JsonString = JsonString ; indicates that rule is defined in RFC8259 Figure 2: JsonNTV - ABNF The JsonNTV format is built with the NTVname, NTVvalue and the JsonNTVtype. Two JsonNTV formats are defined: * named format (if NTVname or JsonType is not an empty string): _{ JsonNTVname : JsonNTVvalue }_ * simple format (if NTVname and JsonType are empty string): _JsonNTVvalue_ This format allows full compatibility with existing JSON structures: * a JsonNumber, JsonString, JsonNull or JsonBoolean is the representation of a Vsingle entity, THOMY Expires 21 February 2024 [Page 10] Internet-Draft JSON semantic format (JSON-NTV) August 2023 * a JsonObject with a single member is the representation of an NVsingle or TVsingle entity, * a JsonArray is the representation of a Vlist entity, * a JsonObject without a single member is the representation of a Vlist entity composed with unnamed entities. _Note :_ * _JsonNTV : 21, { ":" : 21 } and { ":json" : 21 } represent the same Vsingle entity,_ 3.2. JsonNTVname JsonNTVname is the concatenation of NTVname and JsonType. If the JsonNTVname contains one colon, the entity is a NTV-single. If the JsonNTVname contains two adjacent colons, the entity is an NTV-list. JsonNTVname is defined in Figure 3, which uses ABNF from [RFC5234]. ; JSON representation of NTVname and NTVtype (JsonNTVname) JsonNTVname = NTVname / (NTVname JsonSepType) / JsonSepType JsonSepType = [singleSep [JsonNTVtype]] / [listSep [JsonNTVtype]] NTVname = JsonString singleSep = ":" ; NTVsingle separator listSep = "::" ; NTVlist separator Figure 3: JsonNTVname - ABNF The JsonSepType is composed with the separator singleSep or listSep and the JsonNTVtype. For NTVsingle entities: - The JsonSepType is identical to the singleSep joined with JsonNTVtype if JsonNTVtype is not "json". - If JsonNTVtype is "json" and JsonNTVvalue is not a JsonArray and not a JsonObject with not a single member, the JsonSepType is empty. THOMY Expires 21 February 2024 [Page 11] Internet-Draft JSON semantic format (JSON-NTV) August 2023 - If JsonNTVtype is "json" and JsonNTVvalue is a JsonArray or a JsonObject with not a single member, the JsonSepType is ":". For NTVlist entities: - The JsonSepType is identical to the listSep joined with JsonNTVtype if JsonNTVtype is not "json". - If JsonNTVtype is "json" and JsonNTVvalue is not a JsonArray and not a JsonObject with not a single member, the JsonSepType is "::". - If JsonNTVtype is "json" and JsonNTVvalue is a JsonArray or a JsonObject with not a single member, the JsonSepType is empty. For NTV entities included in another entity, the JsonSepType MAY be set to : - The empty string if the NTVtype of the structured NTV entity is identical to the NTVtype of the NTV entity, - relative NTVtype if the NTVtype of the structured NTV entity is a Namespace shared with the NTVtype of the NTV entity. 3.3. JsonNTVtype The JSON representation of a NTVtype (JsonNTVtype) is composed by all the nested NamespaceName and the NTVtypeName. The JsonNTVtype is defined in Figure 4, which uses ABNF from [RFC5234]. ; JSON representation of NtvType (JsonNTVtype) JsonNTVtype = JsonNamespaceParent NTVtypeName JsonNamespace = JsonNamespaceParent NamespaceName JsonNamespaceParent = JsonNamespace NamespaceName = [ ["$"] JsonString "." ] NTVtypeName = ["$"] JsonString Figure 4: JsonNTVtype - ABNF _Example for an absolute representation of an NTVtype defined in two nested Namespace in the global Namespace:_ _"ns1.ns2.type"_ THOMY Expires 21 February 2024 [Page 12] Internet-Draft JSON semantic format (JSON-NTV) August 2023 _where:_ _ns1. is a Namespace defined in the global Namespace,_ _ns2. is a Namespace defined in the ns1. Namespace,_ _type is a NTVtype defined in the ns2. Namespace_ 3.4. JsonNTVvalue The JsonNTVvalue is the JsonValue representation of NTVvalue as defined in Figure 5, which uses ABNF from [RFC5234]. ; JSON representation of NTVvalue JsonNTVvalue = JsonNTVsingleValue / JsonNTVlistValue JsonNTVsingleValue = NTVsingleValue JsonNTVlistValue = JsonNTVArrayValue / JsonNTVObjectValue JsonNTVArrayValue = beginArray ListJsonNTVvalue endArray ListJsonNTVvalue = [JsonNTV *( vSep JsonNTV )] JsonNTVObjectValue = beginObject ListJsonNTVmember endObject ListJsonNTVmember = [JsonNTVMember *( vSep JsonNTVMember)] NTVsingleValue = JsonValue Figure 5: JsonNTVvalue - ABNF For a NTVsingle, JsonNTVvalue is the NTVvalue. For a NTVlist, JsonNTValue has two representations: * a JsonArray where JsonElements are the JsonNTV of included NTV entities, * a JsonObject where the JsonMembers are the JsonMembers of the JsonNTV of included NTV entities. _Note:_ _The JsonObject option is available only if all the NTV entities included have a JsonNTVname and all the JsonNTVname are different (e.g. {":point" : [2.3522, 48.8566], ":point" : [4.8357, 45.7640]} is not a valid JSON-value)_ THOMY Expires 21 February 2024 [Page 13] Internet-Draft JSON semantic format (JSON-NTV) August 2023 4. Examples Examples of JsonNTV representation of NTV entities: *Vsingle :* _"lyon"_ _52.5_ _{ ":" : [4.8357, 45.7640] }_ *NVsingle :* _{ "city" : "paris" }_ _{ "paris:" : [4.8357, 45.7640] }_ *TVsingle:* _{ ":point" : [4.8357, 45.7640] }_ *NTVsingle:* _{ "paris:point" : [2.3522, 48.8566] }_ _{ "paris:ntv" : { "coordinate:point" : [4.8357, 45.7640] } }_ *Vlist (composed with JsonArray):* _[4, 45]_ _["paris"]_ _[ [2.3522, 48.8566], {"lyon" : [4.8357, 45.7640]} ]_ _[ { ":point" : [2.3522, 48.8566]}, {":point" : [4.8357, 45.7640]} ]_ _[]_ *Vlist (composed with JsonObject) :* _{ "name": "white", "firstname":"walter", "surname":"heisenberg" }_ _{ "paris:point" : [2.3522, 48.8566] , "lyon" : "france"}_ THOMY Expires 21 February 2024 [Page 14] Internet-Draft JSON semantic format (JSON-NTV) August 2023 _{ "paris" : [2.3522, 48.8566], "" : [4.8357, 45.7640]}_ _{ }_ *NVlist :* _{ "simple list": [4, 45.7]}_ _{ "cities": [{":point": [2.3522, 48.8566]}, {":point": [4.8357, 45.7640]}]}_ *TVlist :* _{ "::point": [[2.3522, 48.8566], {"lyon" : [4.8357, 45.7640]} ] }_ _{ "::dat": [ "2022-01-28T18-23-54Z", "2022-01-28", 1234.78 ] }_ *NTVlist :* _{ "cities::point": [[2.3522, 48.8566], {"lyon": [4.8357, 45.7640]}] }_ _{ "generic date::dat": [ "2022-01-28T18-23-54Z", "2022-01-28", 1234.78]}_ _{ "various::point": [ [2.3, 48.8], { ":date": "2022-01-28"}, {"json": 25 }, { "another NTVlist": [1,2,3]} ]}_ *NTVlist and NVlist (composed with JsonObject) :* _{ "cities::point": { "paris": [2.352, 48.856], "lyon": [4.835, 45.764]}}_ _{ "cities": {"paris:point": [2.3522, 48.8566] , "lyon": "france"}}_ 5. Parsing a JsonValue A first decoding step identifies the following objects: JsonNTVvalue, NTVname (if present), separator (if present), JsonNTVtype (if present). The tables below present the rules for identifying an NTV entity. THOMY Expires 21 February 2024 [Page 15] Internet-Draft JSON semantic format (JSON-NTV) August 2023 +===============+=============+ | JsonValue | NTV entity | +===============+=============+ | JsonPrimitive | Vsingle | +---------------+-------------+ | JsonUnnamed | Vlist | +---------------+-------------+ | JsonArray | Vlist | +---------------+-------------+ | JsonNamed | see Table 2 | +---------------+-------------+ Table 1: Decoding JsonValue +===========+===============+=============================+ | Separator | JsonNTVvalue | NTV entity | +===========+===============+=============================+ | None | JsonPrimitive | NVsingle | +-----------+---------------+-----------------------------+ | None | JsonNamed | NVsingle | +-----------+---------------+-----------------------------+ | None | JsonUnnamed | NVlist | +-----------+---------------+-----------------------------+ | None | JsonArray | NVlist | +-----------+---------------+-----------------------------+ | ":" | JsonValue | TVsingle or NTVSingle | +-----------+---------------+-----------------------------+ | "::" | JsonUnnamed | NVlist or TVlist or NTVlist | +-----------+---------------+-----------------------------+ | "::" | JsonArray | NVlist or TVlist or NTVlist | +-----------+---------------+-----------------------------+ Table 2: Decoding JsonNTVvalue The NTVvalue of NTVsingle is the JsonNTVvalue. The NTVvalue of NTVlist is build by decoding data included in JsonNTVvalue. For NTV entities not included in a NTVlist, the NTVtype is built with: * "json" JsonNTVtype if JsonNTVtype is None and if the NTV entity is a NTVsingle, * the NTVtype build with the JsonNTVType. For NTV entities included in a NTVlist, the NTVtype is built with : THOMY Expires 21 February 2024 [Page 16] Internet-Draft JSON semantic format (JSON-NTV) August 2023 * the JsonNTVtype if it is an absolute NTVtype and if the entity is a NTVsingle, * the concatenation of the JsonNTVtype of the NTVlist and the JsonNTVtype (if it is a relative NTVtype), * the JsonNTVtype of the NTVlist if the JsonNTVtype is None. If the resulting NTVtype is inconsistent, the NTVtype is set to None. The [JSON-NTV] repository gives some examples of NTV usage. 6. NTV extended structure The NTVvalue of NTV entities are JsonValue. In the NTV extended structure, NTVvalue can be every kind of data. With this structure, the NTV representation is a "json like" data where: * JsonNTVvalue is always NTVvalue, * JsonNTVtype is optional (if NTVtype can be deduced from the NTVvalue), * JsonNTVname is optional (if NTVname can be deduced from the NTVvalue). _Examples of NTV extended representation:_ _{ "date object" : [ datetime.date(2022, 1, 18), datetime.date(2023, 1, 12) ] }_ _this "json like" structure can be converted in JsonNTV format:_ _{ "date object::date" : [ "2022-01-18", "2023-01-12" ] }_ 7. IANA Considerations Any JsonValue is a JsonNTVValue and conversely, any JsonNTVvalue is a JsonValue. Thus, any JSON data may or may not be treated as JsonNTV data, so there is no need to create a specific MIME media type for JsonNTV. All properties of the MIME media type "application/json" are applicable. THOMY Expires 21 February 2024 [Page 17] Internet-Draft JSON semantic format (JSON-NTV) August 2023 8. Security Considerations The format used for NTV data exchanges is the JSON format. So, all the security considerations of [RFC8259] apply. The NTV structure provides no cryptographic integrity protection of any kind. 9. References 9.1. Normative References [RFC7946] Butler, H., Daly, M., Doyle, A., Gillies, S., Hagen, S., and T. Schaub, "The GeoJSON Format", RFC 7946, DOI 10.17487/RFC7946, August 2016, . [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, DOI 10.17487/RFC2119, March 1997, . [RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC 2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174, May 2017, . [RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax Specifications: ABNF", STD 68, RFC 5234, DOI 10.17487/RFC5234, January 2008, . [RFC8259] Bray, T., Ed., "The JavaScript Object Notation (JSON) Data Interchange Format", STD 90, RFC 8259, DOI 10.17487/RFC8259, December 2017, . [RFC3339] Klyne, G. and C. Newman, "Date and Time on the Internet: Timestamps", RFC 3339, DOI 10.17487/RFC3339, July 2002, . 9.2. Informative References [JSON-ND] Kleidon, G., "JSON-ND", 2020, . [JSON-NTV] Thomy, P., "JSON-NTV", 2022, . THOMY Expires 21 February 2024 [Page 18] Internet-Draft JSON semantic format (JSON-NTV) August 2023 [OLC] "Google", "Open Location Code", 2016, . [W3C_TAB] "W3C", "Recommendation : Model for Tabular Data and Metadata on the Web", 17 December 2015, . [ISO_3166-1_alpha-2] "ISO", "Codes for the representation of names of countries and their subdivisions - Part 1: Country code", 2020, . Appendix A. Appendix 1 - Global NTVtype and Namespace The structure of NTVtype by Namespace makes it possible to have NTVtype or Namespace corresponding to recognized standards at the global level. A standard NTVtype / Namespace is a NTVtype / Namespace defined in the Global Namespace. The standard NTVtype and Namespace are listed below. A.1. Json Json NTVtype have a generic NTVtype : "json" +=======================+=======================+==================+ | NTVtypeName (generic) | NTVvalue | example NTVvalue | +=======================+=======================+==================+ | json | generic NTVtype | | +-----------------------+-----------------------+------------------+ | number (json) | JsonNumber [RFC8259] | 10 | +-----------------------+-----------------------+------------------+ | boolean (json) | JsonBoolean [RFC8259] | "true" | +-----------------------+-----------------------+------------------+ | null (json) | JsonNull [RFC8259] | "null" | +-----------------------+-----------------------+------------------+ | string (json) | JsonString [RFC8259] | "value" | +-----------------------+-----------------------+------------------+ | array (json) | JsonArray [RFC8259] | [1.1, 2.2] | +-----------------------+-----------------------+------------------+ | object (json) | JsonObject [RFC8259] | {"value1": 1, | | | | "value2": 2} | +-----------------------+-----------------------+------------------+ Table 3: Json NTVtype THOMY Expires 21 February 2024 [Page 19] Internet-Draft JSON semantic format (JSON-NTV) August 2023 A.2. Numbers +===========================+======================+================+ | NTVtypeName | NTVvalue | comment | +===========================+======================+================+ | int | JsonNumber [RFC8259] | integer | +---------------------------+----------------------+----------------+ | int8, int16, int32, int64 | JsonNumber [RFC8259] | signed | | | | integer | +---------------------------+----------------------+----------------+ | uint8, uint16, uint32, | JsonNumber [RFC8259] | unsigned | | uint64 | | integer | +---------------------------+----------------------+----------------+ | float | JsonNumber [RFC8259] | floating | | | | point real | +---------------------------+----------------------+----------------+ | float16, float32, float64 | JsonNumber [RFC8259] | floating | | | | point real | +---------------------------+----------------------+----------------+ Table 4: Numbers NTVtype A.3. Datation Datation NTVtype have a generic NTVtype : "dat" THOMY Expires 21 February 2024 [Page 20] Internet-Draft JSON semantic format (JSON-NTV) August 2023 +===========+========================+============================+ |NTVtypeName| NTVvalue | example NTVvalue | |(generic) | | | +===========+========================+============================+ |year | fullyear [RFC3339] | 1998 | +-----------+------------------------+----------------------------+ |month | month [RFC3339] | 10 | +-----------+------------------------+----------------------------+ |day | mday [RFC3339] day of | 21 | | | month | | +-----------+------------------------+----------------------------+ |wday | wday [RFC3339] day of | 7 | | | week | | +-----------+------------------------+----------------------------+ |yday | yday [RFC3339] day of | 360 | | | year | | +-----------+------------------------+----------------------------+ |week | week [RFC3339] | 38 | +-----------+------------------------+----------------------------+ |hour | hour [RFC3339] | 20 | +-----------+------------------------+----------------------------+ |minute | minute [RFC3339] | 18 | +-----------+------------------------+----------------------------+ |second | second [RFC3339] | 54 | +-----------+------------------------+----------------------------+ |dat | generic NTVtype | | +-----------+------------------------+----------------------------+ |date (dat) | date [RFC3339] | "2022-01-28"" | +-----------+------------------------+----------------------------+ |time (dat) | timespec-base [time- | "T18:23:54", "18:23", | | | fraction][RFC3339] | "T18" | +-----------+------------------------+----------------------------+ |timetz | timespec-base [time- | "T18:23:54+0400" | |(dat) | fraction] time- | | | | zone[RFC3339] | | +-----------+------------------------+----------------------------+ |datetime | iso-date-time (without | "2022-01-28T18-23-54" | |(dat) | time-zone)[RFC3339] | | +-----------+------------------------+----------------------------+ |datetimetz | iso-date-time (with | "2022-01-28T18-23-54+0400" | |(dat) | time-zone)[RFC3339] | | +-----------+------------------------+----------------------------+ Table 5: Datation NTVtype THOMY Expires 21 February 2024 [Page 21] Internet-Draft JSON semantic format (JSON-NTV) August 2023 A.4. Period and Duration +=============+===========+=====================================+ | NTVtypeName | NTVvalue | example NTVvalue | +=============+===========+=====================================+ | duration | duration | "P3Y6M4DT12H30M5S" | | | [RFC3339] | | +-------------+-----------+-------------------------------------+ | timearray | JsonArray | [dat1, dat2] | | | | | | | | _dat1, dat2 have "dat" NTVtypeName_ | +-------------+-----------+-------------------------------------+ | period | period | "2022-01-01 / 2022-01-30" | | | [RFC3339] | | | | | "2022-01-01 / P3Y6M4DT12H30M5S" | +-------------+-----------+-------------------------------------+ Table 6: Period and Duration NTVtype A.5. Location Location NTVtype have a generic NTVtype : "loc". The CRS (Coordinate Reference Systems) is geographic, using the World Geodetic System 1984 (WGS 84) datum, with longitude and latitude units of decimal degrees (EPSG:4326). THOMY Expires 21 February 2024 [Page 22] Internet-Draft JSON semantic format (JSON-NTV) August 2023 +==============+==============+=================================+ | NTVtypeName | NTVvalue | example NTVvalue | | (generic) | | | +==============+==============+=================================+ | loc | generic | | | | NTVtype | | +--------------+--------------+---------------------------------+ | point (loc) | Point | [ 5.12, 45.256 ] _(lon, lat)_ | | | coordinates | | | | [RFC7946] | | +--------------+--------------+---------------------------------+ | line (loc) | LineString | [pt1, pt2, pt3] | | | coordinates | | | | [RFC7946] | _ptx has "point" NTVtypeName_ | +--------------+--------------+---------------------------------+ | polygon | Polygon | [rg1, rg2, rg3] | | (loc) | coordinates | | | | [RFC7946] | _rgx has "line" NTVtypeName_ | +--------------+--------------+---------------------------------+ | multipolygon | MultiPolygon | [pl1, pl2, pl3] | | (loc) | coordinates | | | | [RFC7946] | _plx has "polygon" NTVtypeName_ | +--------------+--------------+---------------------------------+ | bbox (loc) | Bbox | [ -10.0, -10.0, 10.0, 10.0 ] | | | coordinates | | | | [RFC7946] | | +--------------+--------------+---------------------------------+ | geojson | geoJSON | {"type": "point", | | | object | "coordinates": [40.0, 0.0]} | | | [RFC7946] | | +--------------+--------------+---------------------------------+ | codeolc | Open | "8FW4V75V+8F6" | | | Location | | | | Code [OLC] | | +--------------+--------------+---------------------------------+ Table 7: Location NTVtype A.6. Structured data +=============+==================+ | NTVtypeName | NTVvalue | +=============+==================+ | row | row [W3C_TAB] | +-------------+------------------+ | field | column [W3C_TAB] | +-------------+------------------+ | tab | table [W3C_TAB] | THOMY Expires 21 February 2024 [Page 23] Internet-Draft JSON semantic format (JSON-NTV) August 2023 +-------------+------------------+ | ntv | JsonNTV | +-------------+------------------+ Table 8: Structured NTVtype The data structure associated to this NTVtypeName are defined in specific document. A.7. Normalized String +=============+=========+==========================================+ | NTVtypeName |NTVvalue | example NTVvalue | +=============+=========+==========================================+ | uri |URI | "https://www.ietf.org/rfc/rfc3986.txt" | | |(RFC3986)| | | | | "urn:uuid:f81d4fae-7dec- | | | | 11d0-a765-00a0c91e6bf6" | | | | | | | | "geo:13.4125,103.86673" (RFC5870)" | | | | | | | | "info:eu-repo/dai/nl/12345" | | | | | | | | "mailto:John.Doe@example.com" | | | | | | | | "news:comp.infosystems.www.servers.unix" | +-------------+---------+------------------------------------------+ | email |adress | "John Doe " | | |(RFC5322)| | +-------------+---------+------------------------------------------+ | file |file- | "///path/to/file" | | |hier-part| | | |(RFC8089)| "//host.example.com/path/to/file" | +-------------+---------+------------------------------------------+ Table 9: Structured NTVtype Keywords are not defined as Normalized String (eg. "id", "mandatory", "units"), they can be used as custom NTVtype (eg. "$id", "$mandatory", "$units") A.8. Namespace The global Namespace includes Namespaces for countries, dependent territories and special areas as defined in [ISO_3166-1_alpha-2] The JsonNamespace for those Namespace is composed by the two digits of the country following by a dot. THOMY Expires 21 February 2024 [Page 24] Internet-Draft JSON semantic format (JSON-NTV) August 2023 _Example :_ _"fr." is the France JsonNamespace_ _"un." is The United Nations JsonNamespace_ Each Namespace defines a list of included NTVtype and Namespace. A.9. Custom NTVtype and Namespace Custom NTVtype and Namespace can be created in any Namespace. Table 10 below presents some examples of custom NTVtype. +================+=========================================+ | JsonNTVtype | comment or JsonNTV example | +================+=========================================+ | "$id" | defined in the global Namespace | | | | | | eg. { ":$id": 5426849" } | +----------------+-----------------------------------------+ | "$iata" | IATA airport code | | | | | | eg. {"Paris Nord:$iata": "CDG"} | +----------------+-----------------------------------------+ | "$uic.station" | UIC station code | | | | | | eg. {"Nantes station:$uic.station" : | | | "8748100"} | +----------------+-----------------------------------------+ | "fr.$city" | NTVtype "city" in "fr." Namespace | | | | | | eg. {":fr.$city" : "Paris"} | +----------------+-----------------------------------------+ | "$schemaorg." | "schemaorg" catalog | | | | | | eg. { ":$schemaorg.propertyID": "NO2" } | | | | | | { ":$schemaorg.unitText": "mg/m3"} | +----------------+-----------------------------------------+ | "$darwincore." | "darwincore" catalog | | | | | | eg. { ":$darwincore.acceptedNameUsage": | | | "Tamias minimus" } | +----------------+-----------------------------------------+ Table 10: Examples of custom NTVtype THOMY Expires 21 February 2024 [Page 25] Internet-Draft JSON semantic format (JSON-NTV) August 2023 Appendix B. Appendix 2 - Complete ABNF notation ; JSON representation of NTV entities (JsonNTV) JsonNTV = JsonNTVnamed / JsonNTVsimple JsonNTVnamed = beginObject JsonNTVMember endObject JsonNTVsimple = JsonNTVvalue JsonNTVMember = JsonNTVname nSep JsonNTVvalue ; Extract of JSON grammar used in this document beginArray = ws "[" ws beginObject = ws "{" ws endArray = ws "]" ws endObject = ws "}" ws nSep = ws ":" ws vSep = ws "," ws ws = *( %x20 / %x09 / %x0A / %x0D ) JsonValue = JsonValue ; indicates that rule is defined in RFC8259 JsonString = JsonString ; indicates that rule is defined in RFC8259 ; JSON representation of NTVname and NTVtype (JsonNTVname) JsonNTVname = NTVname / (NTVname JsonSepType) / JsonSepType JsonSepType = [singleSep [JsonNTVtype]] / [listSep [JsonNTVtype]] NTVname = JsonString singleSep = ":" ; NTVsingle separator listSep = "::" ; NTVlist separator ; JSON representation of NtvType (JsonNTVtype) JsonNTVtype = JsonNamespaceParent NTVtypeName JsonNamespace = JsonNamespaceParent NamespaceName JsonNamespaceParent = JsonNamespace NamespaceName = [ ["$"] JsonString "." ] NTVtypeName = ["$"] JsonString ; JSON representation of NTVvalue JsonNTVvalue = JsonNTVsingleValue / JsonNTVlistValue THOMY Expires 21 February 2024 [Page 26] Internet-Draft JSON semantic format (JSON-NTV) August 2023 JsonNTVsingleValue = NTVsingleValue JsonNTVlistValue = JsonNTVArrayValue / JsonNTVObjectValue JsonNTVArrayValue = beginArray ListJsonNTVvalue endArray ListJsonNTVvalue = [JsonNTV *( vSep JsonNTV )] JsonNTVObjectValue = beginObject ListJsonNTVmember endObject ListJsonNTVmember = [JsonNTVMember *( vSep JsonNTVMember)] NTVsingleValue = JsonValue Figure 6: Collected ABNF grammar Acknowledgements TBD Contributors Thanks to all of the contributors. Author's Address Philippe THOMY Loco-labs 476 chemin du gaf de Famian 84 500 BOLLENE France Email: philippe@loco-labs.io URI: https://github.com/loco-philippe/NTV/blob/main/README.md THOMY Expires 21 February 2024 [Page 27]