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.
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:
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
.
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.
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.
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.
All security implications herein are those of the payload.
This XEP requires no interaction with the Internet Assigned Numbers Authority (IANA) [3].
None.
The authors wish to share any credit with many members of the community, including Florian Schmaus, Daniel Gultsch, Georg Lukas, and others.
This document in other formats: XML PDF
This XMPP Extension Protocol is copyright © 1999 – 2020 by the XMPP Standards Foundation (XSF).
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.
## 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. ##
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.
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).
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.
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.
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/about/discuss.shtml> for a complete list.
Errata can be sent to <editor@xmpp.org>.
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".
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/>.
Note: Older versions of this specification might be available at https://xmpp.org/extensions/attic/
Have another crack at getting this through Council.
@report{cridland2019udt, title = {Simple JSON Messaging}, author = {Cridland, Dave}, type = {XEP}, number = {0432}, version = {0.1.1}, institution = {XMPP Standards Foundation}, url = {https://xmpp.org/extensions/xep-0432.html}, date = {2019-12-30/2022-04-12}, }
END