%ents; ]>
JSON Containers This specification defines an element to be used for encapsulating JSON data in XMPP. &LEGALNOTICE; 0335 Deferred Standards Track Standards Council XMPP Core RFC 4627 NOT_YET_ASSIGNED &mwild; 0.1 2013-10-25 psa

Initial published version approved by the XMPP Council.

0.0.2 2013-10-09 mw

Update namespace to urn:xmpp:json:0, add requirement for encapsulation within other protocols, and require conformance to RFC 4627.

0.0.1 2012-11-15 mw

First draft.

JSON is an increasingly popular format for data representation. While investigation has shown us that it cannot feasibly replace XML in all its uses (&xep0295;) sometimes existing data is already in JSON or it is necessary to integrate with systems that use JSON while avoiding the overhead of marshalling that data to or from XML.

Traditional approaches have ranged from simply placing the XML into existing freeform text containers in XMPP (such as the message <body> tag or the presence <status> tag) to creating dedicated containers in a custom namespace. Neither of these approaches are ideal for preserving the extensibility or interoperability that XMPP provides.

This document aims to solve the problem by defining a standard way to embed JSON into any XMPP stanza, and even allowing its use with existing XMPP protocols where possible.

This specification should:

Since JSON generally isn't designed for end-user presentation, most use-cases centre around JSON as part of machine-to-machine communication, or as part of a higher protocol, such as &xep0060;.

{ "name": "romeo", "age": "421", "status": "single" } ]]> { "name": "romeo" } ]]>

The <json> element MUST only contain character data, and the data MUST conform to &rfc4627;. Specifically, the element MUST NOT be empty, as the empty string is not valid JSON. The data MUST be encoded as UTF-8 (though officially unspecified, this is the de facto encoding for JSON today).

Implementations SHOULD validate JSON they receive and intend to use, and be prepared to handle invalid data appropriately (such as by responding to the sender with the applicable XMPP error reply for the stanza type).

As the <json> element alone provides no context to the recipient about the kind of data it contains, only the format, it SHOULD always be encapsulated within another element that provides a context and SHOULD NOT be added as a direct child of a stanza.

The JSON container element is intended for communicating small pieces of generic JSON data within a particular context. XMPP entities MUST NOT attempt to interpret unexpected JSON data they receive, and servers SHOULD NOT inspect JSON data inside stanzas they are routing, other than for OPTIONAL validation.

When generating stanzas containing JSON payloads, implementations should be aware of the maximum stanza size considerations laid down in &xmppcore;.

Embedding JSON is not intended as a substitute for the use of XML in XMPP, and no attempt should be made by protocol designers to use it as such. XMPP implementations are optimised for XML processing, and introducing mixed-format protocols on top of existing XMPP constructs could lead to performance and security considerations beyond the scope of this document.

JSON is a very common format for data interchange today, and has many popular implementations available in browsers and standalone libraries that can be assumed relatively well-tested. However an implementation receiving JSON data from an untrusted entity should take precautions and MUST NOT attempt to use invalid JSON data it receives in any way, nor must it accept data in any encoding other than UTF-8 to avoid potential encoding mismatch attacks.

N/A.

TBD.

This schema is descriptive, not normative.

The protocol documented by this schema is defined in XEP-xxxx: http://www.xmpp.org/extensions/xep-xxxx.html ]]>