RFC 7493
The I-JSON Message Format
RFC 7493: The I-JSON Message Format ๐
Okay bestie, first the vibe check ๐. This is RFC 7493, titled "The I-JSON Message Format". It was edited by T. Bray, Ed. (Tim Bray) at Textuality Services, and it came out in March 2015. It's a Standards Track document, which means it's an official Internet standard, not just a suggestion ๐. The ISSN is 2070-1721. The title block doesn't list anything it obsoletes or updates, so it stands on its own โจ.
Okay the table of contents is next, and I'm keeping it exactly as it is ๐ง
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 2
1.1. Terminology . . . . . . . . . . . . . . . . . . . . . . . 2
1.2. Requirements Language . . . . . . . . . . . . . . . . . . 2
2. I-JSON Messages . . . . . . . . . . . . . . . . . . . . . . . 3
2.1. Encoding and Characters . . . . . . . . . . . . . . . . . 3
2.2. Numbers . . . . . . . . . . . . . . . . . . . . . . . . . 3
2.3. Object Constraints . . . . . . . . . . . . . . . . . . . 3
3. Software Behavior . . . . . . . . . . . . . . . . . . . . . . 4
4. Recommendations for Protocol Design . . . . . . . . . . . . . 4
4.1. Top-Level Constructs . . . . . . . . . . . . . . . . . . 4
4.2. Must-Ignore Policy . . . . . . . . . . . . . . . . . . . 4
4.3. Time and Date Handling . . . . . . . . . . . . . . . . . 5
4.4. Binary Data . . . . . . . . . . . . . . . . . . . . . . . 5
5. Security Considerations . . . . . . . . . . . . . . . . . . . 5
6. Normative References . . . . . . . . . . . . . . . . . . . . 5
Acknowledgements . . . . . . . . . . . . . . . . . . . . . . . . 6
Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 6
Abstract
Okay, so I-JSON (short for "Internet JSON") is a restricted profile of JSON. Its whole job is to maximize interoperability and make software way more likely to process it successfully with predictable results ๐
โจ.
Status of This Memo
This is an Internet Standards Track document ๐.
This document is a product of the Internet Engineering Task Force (IETF). It represents the consensus of the IETF community. It has received public review and has been approved for publication by the Internet Engineering Steering Group (IESG). If you want more on Internet Standards, check out Section 2 of RFC 5741 ๐ฆ.
For the current status of this document, any errata, and how to give feedback, go to http://www.rfc-editor.org/info/rfc7493 ๐ธ.
Copyright Notice
Copyright (c) 2015 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 (http://trustee.ietf.org/license-info) as they stand on the date this document was published. Please read these carefully, because they're the rules for what you're allowed to do and not do with this document ๐. Code Components pulled out of this document must include Simplified BSD License text, as described in Section 4.e of the Trust Legal Provisions, and they come without warranty, as described in the Simplified BSD License ๐.
1. Introduction ๐
RFC 7159 describes the JSON data interchange format, and it's used all over Internet protocols. For historical reasons, that spec lets people use language idioms and text encoding patterns that can cause interoperability problems and software breakage. This gets especially messy when a program receiving JSON uses automated software to map it into native programming-language structures or database records ๐. RFC 7159 describes practices that may be used to avoid these interoperability problems ๐ซถ.
This document specifies I-JSON, short for "Internet JSON". The unit of definition is the "I-JSON message". I-JSON messages are also "JSON texts" as defined in RFC 7159, but with some extra constraints that enforce the good interoperability practices from that spec โจ.
1.1. Terminology ๐งธ
The terms "object", "member", "array", "number", "name", and "string" in this document are to be interpreted as described in RFC 7159 [RFC7159].
1.2. Requirements Language ๐
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 [RFC2119] ๐.
2. I-JSON Messages ๐
An I-JSON message is a JSON text, as defined by RFC 7159 ๐.
2.1. Encoding and Characters ๐ค
I-JSON messages MUST be encoded using UTF-8 [RFC3629]. No skipping this, periodt ๐ .
Object member names, and string values in arrays and object members, MUST NOT include code points that identify Surrogates or Noncharacters as defined by [UNICODE] ๐.
This applies both to characters encoded directly in UTF-8 and to characters that are escaped. So "\uDEAD" is invalid because it's an unpaired surrogate, while "\uD800\uDEAD" would be legal ๐ญ.
2.2. Numbers ๐ข
Software that implements IEEE 754-2008 binary64 (double precision) numbers [IEEE754] is generally available and widely used ๐
. Implementations that generate I-JSON messages can't assume that receiving implementations can handle numeric values with greater magnitude or precision than those numbers provide. I-JSON messages SHOULD NOT include numbers that express greater magnitude or precision than an IEEE 754 double precision number provides, for example 1E400 or 3.141592653589793238462643383279 ๐.
An I-JSON sender can't expect a receiver to treat an integer as an exact value if its absolute value is greater than 9007199254740991 (i.e., if it's outside the range [-(2**53)+1, (2**53)-1]) ๐.
For applications that need exact interchange of numbers with greater magnitude or precision, it is RECOMMENDED to encode them in JSON string values ๐. This requires that the receiving program understand the intended semantic of the value. An example would be 64-bit integers, even though modern hardware can deal with them, because of the limited scope of JavaScript numbers ๐ง.
2.3. Object Constraints ๐งฑ
Objects in I-JSON messages MUST NOT have members with duplicate names ๐ซ. In this context, "duplicate" means that the names, after processing any escaped characters, are identical sequences of Unicode characters.
The order of object members in an I-JSON message doesn't change its meaning. A receiving implementation MAY treat two I-JSON messages as equivalent if they differ only in the order of the object members ๐ฆ.
3. Software Behavior ๐ธ
A major perk of I-JSON is that receivers can avoid ambiguous semantics in the JSON messages they get. This means receivers can reject or otherwise ignore messages that don't meet the I-JSON requirements in this document ๐. Protocols that use I-JSON messages can be written so that receiving implementations are required to reject (or, in the case of security protocols, not trust) messages that don't satisfy I-JSON constraints ๐ฅ.
Designers of protocols that use I-JSON messages SHOULD provide a way, in this case, for the receiver of the erroneous data to signal the problem to the sender ๐.
4. Recommendations for Protocol Design ๐
I-JSON is designed for Internet protocols, so the following recommendations apply when you use it in those ๐.
4.1. Top-Level Constructs ๐งฉ
An I-JSON message can be any JSON value. BUT, there are software implementations, coded to the older specification [RFC4627], that only accept JSON objects or JSON arrays at the top level of JSON texts ๐. For maximum interoperability with those implementations, protocol designers SHOULD NOT use top-level JSON texts that are neither objects nor arrays ๐ซถ.
4.2. Must-Ignore Policy ๐ก๏ธ
Protocols often need changes after they've gone into production. Protocols that let you add new protocol elements without disrupting existing software have proven really useful in practice โจ.
This can be called a "Must-Ignore" policy. When an implementation runs into a protocol element it doesn't recognize, it should treat the rest of the protocol transaction as if the new element simply didn't appear. In particular, the implementation MUST NOT treat this as an error condition ๐. The converse, the "Must-Understand" policy, doesn't tolerate new protocol elements at all. That has been necessary in some protocol designs, but in general it's been found to be too restrictive and brittle ๐ฉ.
A good way to support Must-Ignore in I-JSON protocol designs is to require that top-level protocol elements must be JSON objects, and to specify that members whose names are unrecognized MUST be ignored ๐ง.
4.3. Time and Date Handling โฐ
Protocols often have data items meant to hold timestamps or time durations. It is RECOMMENDED that all of these data items be expressed as string values in ISO 8601 format, as specified in [RFC3339]. There are a few extra rules: uppercase letters rather than lowercase letters are used, the timezone is included and not defaulted, and optional trailing seconds are included even when their value is "00" ๐. It is also RECOMMENDED that all data items containing time durations conform to the "duration" production in Appendix A of RFC 3339, with the same additional restrictions ๐.
4.4. Binary Data ๐ง
When an I-JSON protocol element is required to contain arbitrary binary data, it is RECOMMENDED that this data be encoded in a string value in base64url. See Section 5 of [RFC4648] ๐ซ.
5. Security Considerations ๐จ
All the security considerations that apply to JSON (see RFC 7159) apply to I-JSON too. There are no additional security considerations specific to I-JSON ๐.
Okay, this part is actually important. Since I-JSON forbids certain JSON idioms that can lead to unpredictable behavior in receiving software, it may prove to be a more secure basis for Internet protocols. It may be a great choice for protocol designers with special security needs ๐ก๏ธ๐.
6. Normative References ๐
- [IEEE754] IEEE, "IEEE Standard for Floating-Point Arithmetic", IEEE 754-2008, 2008,
<http://grouper.ieee.org/groups/754/>. - [RFC2119] Bradner, S., "Key words for use in RFCs to Indicate Requirement Levels", BCP 14, RFC 2119, March 1997,
<http://www.rfc-editor.org/info/rfc2119>. - [RFC3339] Klyne, G. and C. Newman, "Date and Time on the Internet: Timestamps", RFC 3339, July 2002,
<http://www.rfc-editor.org/info/rfc3339>. - [RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO 10646", STD 63, RFC 3629, November 2003,
<http://www.rfc-editor.org/info/rfc3629>. - [RFC4627] Crockford, D., "The application/json Media Type for JavaScript Object Notation (JSON)", RFC 4627, July 2006,
<http://www.rfc-editor.org/info/rfc4627>. - [RFC4648] Josefsson, S., "The Base16, Base32, and Base64 Data Encodings", RFC 4648, October 2006,
<http://www.rfc-editor.org/info/rfc4648>. - [RFC7159] Bray, T., Ed., "The JavaScript Object Notation (JSON) Data Interchange Format", RFC 7159, March 2014,
<http://www.rfc-editor.org/info/rfc7159>. - [UNICODE] The Unicode Consortium, "The Unicode Standard",
<http://www.unicode.org/versions/latest/>.
Acknowledgements ๐ซถ
I-JSON depends entirely on the design of JSON, and that's largely thanks to Douglas Crockford ๐. The specifics were strongly influenced by the contributors to the design of RFC 7159 in the IETF JSON Working Group ๐.
Author's Address ๐ฎ
Tim Bray (editor) Textuality Services
EMail: tbray@textuality.com URI: https://www.tbray.org/
๐ฆ where this page comes from
- ietf: rfc7493 2015-03
- ๐ girlified by claude-haiku-5-5 on : a language model's rewrite of the original, under its terms