idnits 2.17.1 draft-rsalz-jsonx-00.txt: Checking boilerplate required by RFC 5378 and the IETF Trust (see https://trustee.ietf.org/license-info): ---------------------------------------------------------------------------- No issues found here. Checking nits according to https://www.ietf.org/id-info/1id-guidelines.txt: ---------------------------------------------------------------------------- == No 'Intended status' indicated for this document; assuming Proposed Standard Checking nits according to https://www.ietf.org/id-info/checklist : ---------------------------------------------------------------------------- ** The document seems to lack a Security Considerations section. ** The document seems to lack an IANA Considerations section. (See Section 2.2 of https://www.ietf.org/id-info/checklist for how to handle the case when there are no actions for IANA.) ** There are 5 instances of too long lines in the document, the longest one being 12 characters in excess of 72. Miscellaneous warnings: ---------------------------------------------------------------------------- == The copyright year in the IETF Trust and authors Copyright Line does not match the current year -- The document date (May 2, 2011) is 4733 days in the past. Is this intentional? Checking references for intended status: Proposed Standard ---------------------------------------------------------------------------- (See RFCs 3967 and 4897 for information about using normative references to lower-maturity documents in RFCs) ** Obsolete normative reference: RFC 4627 (Obsoleted by RFC 7158, RFC 7159) -- Possible downref: Non-RFC (?) normative reference: ref. 'REC-xml' -- Possible downref: Non-RFC (?) normative reference: ref. 'REC-xml-infoset' Summary: 4 errors (**), 0 flaws (~~), 2 warnings (==), 3 comments (--). Run idnits with the --verbose option for more detailed information about the items above. -------------------------------------------------------------------------------- 2 Network Working Group B. Muschett 3 Internet-Draft R. Salz 4 Expires: November 3, 2011 M. Schenker 5 IBM 6 May 2, 2011 8 JSONx, an XML Encoding for JSON 9 draft-rsalz-jsonx-00.txt 11 Abstract 13 This document specifies a mapping between JSON (RFC 4627) and XML. 14 The mapping maintains a high degree of fidelity. It is used by 15 several IBM products. 17 Status of this Memo 19 This Internet-Draft is submitted in full conformance with the 20 provisions of BCP 78 and BCP 79. 22 Internet-Drafts are working documents of the Internet Engineering 23 Task Force (IETF). Note that other groups may also distribute 24 working documents as Internet-Drafts. The list of current Internet- 25 Drafts is at http://datatracker.ietf.org/drafts/current/. 27 Internet-Drafts are draft documents valid for a maximum of six months 28 and may be updated, replaced, or obsoleted by other documents at any 29 time. It is inappropriate to use Internet-Drafts as reference 30 material or to cite them other than as "work in progress." 32 This Internet-Draft will expire on November 3, 2011. 34 Copyright Notice 36 Copyright (c) 2011 IETF Trust and the persons identified as the 37 document authors. All rights reserved. 39 This document is subject to BCP 78 and the IETF Trust's Legal 40 Provisions Relating to IETF Documents 41 (http://trustee.ietf.org/license-info) in effect on the date of 42 publication of this document. Please review these documents 43 carefully, as they describe your rights and restrictions with respect 44 to this document. Code Components extracted from this document must 45 include Simplified BSD License text as described in Section 4.e of 46 the Trust Legal Provisions and are provided without warranty as 47 described in the Simplified BSD License. 49 Table of Contents 51 1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . . 3 52 2. Conversion Rules . . . . . . . . . . . . . . . . . . . . . . . 4 53 2.1. root element . . . . . . . . . . . . . . . . . . . . . . . 4 54 2.2. object . . . . . . . . . . . . . . . . . . . . . . . . . . 4 55 2.3. array . . . . . . . . . . . . . . . . . . . . . . . . . . 4 56 2.4. boolean . . . . . . . . . . . . . . . . . . . . . . . . . 5 57 2.5. string . . . . . . . . . . . . . . . . . . . . . . . . . . 5 58 2.6. number . . . . . . . . . . . . . . . . . . . . . . . . . . 5 59 2.7. null . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 60 3. Extended Example . . . . . . . . . . . . . . . . . . . . . . . 7 61 4. Normative References . . . . . . . . . . . . . . . . . . . . . 8 62 Appendix A. Schema (not normative) . . . . . . . . . . . . . . . 9 63 Appendix B. JSONx to JSON Stylesheet (not normative) . . . . . . 11 64 Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 13 66 1. Introduction 68 This document specifies a mapping between JSON [RFC4627] and XML, 69 known as JSONx. The mapping maintains a high degree of fidelity. It 70 is used by several IBM products. 72 JSONx is specified using the terms from the XML Infoset 73 [REC-xml-infoset], serialized as XML 1.0 [REC-xml]. The Infoset 74 terms "Element Information Item," "Attribute Information Item," and 75 "Character Information Item," are shortened to "element," 76 "attribute," and "characters" respectively. For example, when this 77 specification uses the term "element," it is referring to an Element 78 Information Item, and when it uses the term "attribute," it is 79 referring to an Attribute Information Item. 81 2. Conversion Rules 83 JSON identifiers are represented by the string contents of the "name" 84 attribute. Most Unicode characters other than backspace (Unicode 85 code point U+0008) and form feed (U+000C) are valid within 86 identifiers, as long as they are properly escaped (for example, 87 \unnnn). When JSONx is serialized as XML documents, character and/or 88 entity references may need to be used for special characters. 89 Examples of this include ampersand (U+0026), less-then sign (U+003C), 90 and any characters not representable in the document's encoding. 92 Use of backspace, formfeed, or NUL (U+0000) is undefined. 94 2.1. root element 96 The root element is either a or a element 97 with the following namespace declaration: 99 +--------+------------------------------------------+ 100 | Prefix | Namespace URI | 101 +--------+------------------------------------------+ 102 | json | http://www.ibm.com/xmlns/prod/2009/jsonx | 103 +--------+------------------------------------------+ 105 All elements defined in this document are in that namespace. 107 2.2. object 109 A JSON object becomes a element. If the object denotes 110 a property within a JSON object, JSONx encodes a name attribute whose 111 value is assigned the property name. The child elements depend on 112 the properties of the JSON object. To improve readability, 113 whitespace characters may be added between child elements. Object 114 elements are ordered according to their document order. 116 { "Ticker" : "IBM" } 118 119 IBM 120 122 2.3. array 124 A JSON array becomes a element. If the array denotes a 125 property within a JSON object, JSONx encodes a name attribute whose 126 value is assigned the property name. The child elements depend on 127 the values in the array. To improve readability, whitespace 128 characters may be added between child elements. 130 "phoneNumbers": [ 131 "212 555-1111", 132 "212 555-2222" 133 ] 135 136 212 555-1111 137 212 555-2222 138 140 2.4. boolean 142 A JSON boolean becomes a element. If the boolean 143 denotes a property within a JSON object, JSONx encodes a name 144 attribute whose value is assigned the property name. The boolean 145 value is character data as either true or false. 147 "remote": false 149 false 151 2.5. string 153 A JSON string becomes a element. If the string denotes 154 a property within a JSON object, JSONx encodes a name attribute whose 155 value is assigned the property name. The string value is character 156 data. 158 Use of the Unicode code points U+0000, U+0008, and U+000C is 159 undefined. 161 "name": "John Smith" 163 John Smith 165 2.6. number 167 A JSON number becomes a element. If the number denotes 168 a property within a JSON object, JSONx encodes a name attribute whose 169 value is assigned the property name. The number value is character 170 data. 172 "height": 62.4 174 62.4 176 2.7. null 178 JSON value of null becomes a element. If the null value 179 denotes a property within a JSON object, JSONx encodes a name 180 attribute whose value is assigned the property name. This element 181 has no content. 183 "additionalInfo": null 185 187 3. Extended Example 189 The following example document is a sample of the JSON structure. 191 { 192 "name": "John Smith" 193 "address": { 194 "streetAddress": "21 2nd Street", 195 "city": "New York", 196 "state": "NY", 197 "postalCode": 10021, 198 }, 199 "phoneNumbers": [ 200 "212 555-1111", 201 "212 555-2222" 202 ], 203 "additionalInfo": null, 204 "remote": false, 205 "height": 62.4, 206 "ficoScore": "> 640" 207 } 209 The following output is the result of the transformed document as 210 JSONx. 212 213 214 John Smith 215 216 21 2nd Street 217 New York 218 NY 219 10021 220 221 222 212 555-1111 223 212 555-2222 224 225 226 false 227 62.4 228 > 640 229 231 4. Normative References 233 [RFC4627] Crockford, D., "The application/json Media Type for 234 JavaScript Object Notation (JSON)", RFC 4627, July 2006. 236 [REC-xml] Yergeau, F., Paoli, J., Bray, T., Sperberg-McQueen, C., 237 and E. Maler, "Extensible Markup Language (XML) 1.0 238 (Fourth Edition)", World Wide Web Consortium 239 Recommendation REC-xml-20060816, August 2006, 240 . 242 [REC-xml-infoset] 243 Cowan, J. and R. Tobin, "XML Information Set (Second 244 Edition)", World Wide Web Consortium Recommendation REC- 245 xml-infoset-20040204, February 2004, 246 . 248 Appendix A. Schema (not normative) 250 251 256 257 258 259 260 262 263 264 265 266 267 269 270 271 273 274 275 277 278 279 281 282 283 284 285 286 287 289 290 291 292 293 294 295 296 297 298 299 300 301 302 304 305 Appendix B. JSONx to JSON Stylesheet (not normative) 307 The following XSLT stylesheet takes a JSONx document as input and 308 generates JSON. It is intended as a sample implementation, and makes 309 no attempt to be well-behaved if the input is not well-defined. 311 312 316 319 320 321 322 323 325 326 327 { 328 329 330 331 , 332 333 334 } 335 337 338 339 [ 340 341 342 343 , 344 345 346 ] 347 349 350 351 " 352 353 354 " 355 357 358 359 360 362 363 364 365 367 368 369 null 370 372 373 Authors' Addresses 375 Brien Muschett 376 IBM 377 8051 Congress Avenue 378 Boca Raton, FL 33487 379 USA 381 Phone: +1 561-862-2180 382 Email: muschett@us.ibm.com 384 Rich Salz 385 IBM 386 550 King Street 387 Littleton, MA 01460 388 USA 390 Phone: +1 978-899-2902 391 Email: rsalz@us.ibm.com 392 URI: https://www.ibm.com/developerworks/mydeveloperworks/blogs/soma/ 394 Michael Schenker 395 IBM 396 555 Bailey Ave. 397 San Jose, CA 95141 398 USA 400 Phone: +1 408-463-3907 401 Email: mschenk@us.ibm.com