XEP-XXXX: Simple JSON Messaging

Abstract
This specification proposes a simple mechanism by which applications can transfer data safely, without needing additional protocol design work. It is intended to provide a protocol that is trivial to implement and can be driven with a simple API.
Author
Dave Cridland
Copyright
© 2019 – 2020 XMPP Standards Foundation. SEE LEGAL NOTICES.
Status

ProtoXEP

WARNING: This document has not yet been accepted for consideration or approved in any official manner by the XMPP Standards Foundation, and this document is not yet an XMPP Extension Protocol (XEP). If this document is accepted as a XEP by the XMPP Council, it will be published at <https://xmpp.org/extensions/> and announced on the <standards@xmpp.org> mailing list.
Type
Standards Track
Version
0.0.2 (2020-02-13)
Document Lifecycle
  1. Experimental
  2. Proposed
  3. Stable
  4. Final

1. Introduction

Applications written on top of XMPP often need to exchange data that has no existing standard. Such applications are often written by developers unfamiliar with best practise in designing new extensions for XMPP, making it hard to achieve this simple design goal without causing longer term problems.

This leads to "solutions" such as stuffing JSON directly in the <body/> element, for example, and recognising this at the receiver either by heuristics or by a special <subject/>. While this works, it is difficult to then migrate to something else, and enforces that custom clients are always used.

Therefore this document proposes a very simple (and simplistic) framework for sending such data which - while very light on features - nevertheless conforms to best practice, and yields an interoperable protocol. Unusually, this specification SHOULD NOT be used as a base upon which to build other standards.

1.1 Terminology

Data transferred using this specification is encoded using JSON. The type of the data is given by a URI under the same rules as an XML namespace, and this specification refers to this as the datatype.

Because this document defines mechanisms for sending essentially arbitrary data, no real-world examples are given.

Instead, example namespaces are used within an XML namespace prefixed by urn:example:

2. Overview

2.1 Discovering Support

Support for this protocol is advertised by the Service Discovery protocol defined in Service Discovery (XEP-0030) [1] using a feature of urn:xmpp:json-msg:0.

Support for a particular datatype is given by concatenating the urn:xmpp:json-msg:0 feature with a hash character ('#') and the datatype, for example urn:xmpp:json-msg:0#urn:example:foo.

2.2 Data Transfers

Simple JSON Messaging payloads may also be placed within a <message/> stanza. <message/> stanzas MAY contain multiple UDT payloads, but typical usage is expected to be that there will be only one. The JSON Messaging payload may be ancillary data to another message, or a standalone message in its own right.

2.2.1 Protocol Syntax

A Simple JSON Messaging payload consists of a single element, <payload/>, qualified by the XML namespace urn:xmpp:json-msg:0. It has a single, mandatory attribute of datatype, which MUST contain a string conformant to the requirements for XML namespaces (typically a URI under the control of the application developer).

As with XML namespaces, this URI is never expected to be resolved, and is used solely as an identifier. Different strings are considered entirely different datatypes, and common prefixes etc MUST be considered irrelevant for the purposes of interpreting the data. There are no common or standard datatypes.

The <payload element contains exactly one mandatory child element, the <json/> element defined in JSON Containers (XEP-0335) [2]. This in turns contains the JSON data.

Example 1.
<message from="gamer@game-company.example"
    to="match-maker.game-company.example"
    id="12345">
  <payload xmlns="urn:xmpp:json-msg:0" datatype="urn:example:foo">
    <json xmlns="urn:xmpp:json:0">
      {
        "annoying-teenager-level": 11
      }
    </json>
  </payload>
</message>

3. API Requirements

In order to satisfy the goals of this protocol, client library developers are encouraged to provide a simple to use API for this protocol. Developers are encouraged to use terms such as "JSON Message" in their API calls and documentation.

Support for a particular datatype SHOULD be advertised automatically when listening for custom messages of that type if possible.

4. Schema

      
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" targetNamespace="urn:xmpp:json-msg:0" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="payload" type="udt:payloadType" xmlns:udt="urn:xmpp:json-msg:0"/>
  <xs:complexType name="payloadType">
    <xs:sequence>
      <xs:any minOccurs="1" maxOccurs="1"/>
      <!-- Always a XEP-0335 json element, but I can't figure that out. -->
    </xs:sequence>
    <xs:attribute type="xs:string" name="datatype"/>
  </xs:complexType>
</xs:schema>
      
    

5. Security Considerations

All security implications herein are those of the payload.

6. IANA Considerations

This XEP requires no interaction with the Internet Assigned Numbers Authority (IANA) [3].

7. XMPP Registrar Considerations

None.

8. Acknowledgements

The authors wish to share any credit with many members of the community, including Florian Schmaus, Daniel Gultsch, Georg Lukas, and others.


Appendices

Appendix A: Document Information

Series
XEP
Number
XXXX
Publisher
XMPP Standards Foundation
Status
ProtoXEP
Type
Standards Track
Version
0.0.2
Last Updated
2020-02-13
Approving Body
XMPP Council
Dependencies
XMPP Core
Supersedes
None
Superseded By
None
Short Name
udt

This document in other formats: XML  PDF

Appendix B: Author Information

Dave Cridland
Email
dave@hellopando.com
JabberID
dwd@dave.cridland.net

Copyright

This XMPP Extension Protocol is copyright © 1999 – 2024 by the XMPP Standards Foundation (XSF).

Permissions

Permission is hereby granted, free of charge, to any person obtaining a copy of this specification (the "Specification"), to make use of the Specification without restriction, including without limitation the rights to implement the Specification in a software program, deploy the Specification in a network service, and copy, modify, merge, publish, translate, distribute, sublicense, or sell copies of the Specification, and to permit persons to whom the Specification is furnished to do so, subject to the condition that the foregoing copyright notice and this permission notice shall be included in all copies or substantial portions of the Specification. Unless separate permission is granted, modified works that are redistributed shall not contain misleading information regarding the authors, title, number, or publisher of the Specification, and shall not claim endorsement of the modified works by the authors, any organization or project to which the authors belong, or the XMPP Standards Foundation.

Disclaimer of Warranty

## NOTE WELL: This Specification is provided on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. ##

Limitation of Liability

In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall the XMPP Standards Foundation or any author of this Specification be liable for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising from, out of, or in connection with the Specification or the implementation, deployment, or other use of the Specification (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if the XMPP Standards Foundation or such author has been advised of the possibility of such damages.

IPR Conformance

This XMPP Extension Protocol has been contributed in full conformance with the XSF's Intellectual Property Rights Policy (a copy of which can be found at <https://xmpp.org/about/xsf/ipr-policy> or obtained by writing to XMPP Standards Foundation, P.O. Box 787, Parker, CO 80134 USA).

Visual Presentation

The HTML representation (you are looking at) is maintained by the XSF. It is based on the YAML CSS Framework, which is licensed under the terms of the CC-BY-SA 2.0 license.

Appendix D: Relation to XMPP

The Extensible Messaging and Presence Protocol (XMPP) is defined in the XMPP Core (RFC 6120) and XMPP IM (RFC 6121) specifications contributed by the XMPP Standards Foundation to the Internet Standards Process, which is managed by the Internet Engineering Task Force in accordance with RFC 2026. Any protocol defined in this document has been developed outside the Internet Standards Process and is to be understood as an extension to XMPP rather than as an evolution, development, or modification of XMPP itself.

Appendix E: Discussion Venue

The primary venue for discussion of XMPP Extension Protocols is the <standards@xmpp.org> discussion list.

Discussion on other xmpp.org discussion lists might also be appropriate; see <https://xmpp.org/community/> for a complete list.

Errata can be sent to <editor@xmpp.org>.

Appendix F: Requirements Conformance

The following requirements keywords as used in this document are to be interpreted as described in RFC 2119: "MUST", "SHALL", "REQUIRED"; "MUST NOT", "SHALL NOT"; "SHOULD", "RECOMMENDED"; "SHOULD NOT", "NOT RECOMMENDED"; "MAY", "OPTIONAL".

Appendix G: Notes

1. XEP-0030: Service Discovery <https://xmpp.org/extensions/xep-0030.html>.

2. XEP-0335: JSON Containers <https://xmpp.org/extensions/xep-0335.html>.

3. The Internet Assigned Numbers Authority (IANA) is the central coordinator for the assignment of unique parameter values for Internet protocols, such as port numbers and URI schemes. For further information, see <http://www.iana.org/>.

Appendix H: Revision History

Note: Older versions of this specification might be available at https://xmpp.org/extensions/attic/

  1. Version 0.0.2 (2020-02-13)

    Have another crack at getting this through Council.

    dwd
  2. Version 0.0.1 (2019-12-30)
    dwd

Appendix I: Bib(La)TeX Entry

@report{cridland2019udt,
  title = {Simple JSON Messaging},
  author = {Cridland, Dave},
  type = {XEP},
  number = {XXXX},
  version = {0.0.2},
  institution = {XMPP Standards Foundation},
  url = {https://xmpp.org/extensions/xep-XXXX.html},
  date = {2019-12-30/2020-02-13},
}

END