Ecma/TC39/2013/NN. 4 th Draft ECMA-XXX. 1 st Edition / July 2013. The JSON Data Interchange Format. Reference number ECMA-123:2009



Similar documents
Request for Comments: 4627 Category: Informational July The application/json Media Type for JavaScript Object Notation (JSON)

ECMA-400. Smart Data Centre Resource Monitoring and Control. 1 st Edition / December Reference number ECMA-123:2009

Pemrograman Dasar. Basic Elements Of Java

How To Write A Wsdl Standard For Csta (Ecma) And Cst A) (Ecmma)

INTERNATIONAL TELECOMMUNICATION UNION

Web Browser Session Restore Forensics A valuable record of a user s internet activity for computer forensic examinations

JavaScript: Introduction to Scripting Pearson Education, Inc. All rights reserved.

Chapter 4: Computer Codes

INTERNATIONAL TELECOMMUNICATION UNION

DTD Tutorial. About the tutorial. Tutorial

Number Representation

Request for Comments: Category: Experimental NSA February 2000

Hexadecimal Object File Format Specification

Compiler Construction

Request for Comments: March 2001

Variables, Constants, and Data Types

Bachelors of Computer Application Programming Principle & Algorithm (BCA-S102T)

Towards More Security in Data Exchange

Frequently Asked Questions on character sets and languages in MT and MX free format fields

XML: extensible Markup Language. Anabel Fraga

Numbering Systems. InThisAppendix...

This section describes how LabVIEW stores data in memory for controls, indicators, wires, and other objects.

Systems I: Computer Organization and Architecture

Character Code Structure and Extension Techniques

Structured vs. unstructured data. Motivation for self describing data. Enter semistructured data. Databases are highly structured

Semantic Analysis: Types and Type Checking

PL/JSON Reference Guide (version 1.0.4)

The Unicode Standard Version 8.0 Core Specification

Bypassing Web Application Firewalls (WAFs) Ing. Pavol Lupták, CISSP, CEH Lead Security Consultant

Package PKI. July 28, 2015

Eventia Log Parsing Editor 1.0 Administration Guide

Streaming Lossless Data Compression Algorithm (SLDC)

INTERNATIONAL TELECOMMUNICATION UNION

How to translate VisualPlace

Introduction to Web Services

7-Bit coded Character Set

Unicode Security. Software Vulnerability Testing Guide. July 2009 Casaba Security, LLC

BASI DI DATI II 2 modulo Parte II: XML e namespaces. Prof. Riccardo Torlone Università Roma Tre

HOMEWORK # 2 SOLUTIO

Detailed Specifications

Symbols in subject lines. An in-depth look at symbols

Topics. Parts of a Java Program. Topics (2) CS 146. Introduction To Computers And Java Chapter Objectives To understand:

JavaScript: Control Statements I

Levent EREN A-306 Office Phone: INTRODUCTION TO DIGITAL LOGIC

Name: Class: Date: 9. The compiler ignores all comments they are there strictly for the convenience of anyone reading the program.

Programming languages C

.NET Standard DateTime Format Strings

Last Week. XML (extensible Markup Language) HTML Deficiencies. XML Advantages. Syntax of XML DHTML. Applets. Modifying DOM Event bubbling

HTML Web Page That Shows Its Own Source Code

Cloud Infrastructure Management Interface - Common Information Model (CIMI-CIM)

Counting in base 10, 2 and 16

Package PKI. February 20, 2013

Massachusetts Institute of Technology Department of Electrical Engineering and Computer Science

Requirements for a Long-term Viable, Archive Data Format

Performance Testing for Ajax Applications

Lecture 9. Semantic Analysis Scoping and Symbol Table

TCG. Trusted Platform Module Library Part 2: Structures. TCG Published. Family 2.0. Level 00 Revision October 30, 2014.

Cross Site Scripting Prevention

Network Working Group. Category: Standards Track Novell November 1997

Parsing Technology and its role in Legacy Modernization. A Metaware White Paper

Finding XSS in Real World

RSA SecurID Software Token Security Best Practices Guide

Information Technology Topic Maps Part 2: Data Model

Intel Hexadecimal Object File Format Specification Revision A, 1/6/88

ECMAScript: A general purpose, cross-platform programming language

Server Management Command Line Protocol (SM CLP) Specification

Standard Recommended Practice extensible Markup Language (XML) for the Interchange of Document Images and Related Metadata

Cover Page. Dynamic Server Pages Guide 10g Release 3 ( ) March 2007

Authority file comparison rules Introduction

Data Storage. Chapter 3. Objectives. 3-1 Data Types. Data Inside the Computer. After studying this chapter, students should be able to:

Solution for Homework 2

Data Tool Platform SQL Development Tools

JAVA - QUICK GUIDE. Java SE is freely available from the link Download Java. So you download a version based on your operating system.

This is a preview - click here to buy the full publication INTERNATIONAL STANDARD

Documentation to use the Elia Infeed web services

Perl in a nutshell. First CGI Script and Perl. Creating a Link to a Script. print Function. Parsing Data 4/27/2009. First CGI Script and Perl

WebSphere Business Monitor

Base Conversion written by Cathy Saxton

1. Give the 16 bit signed (twos complement) representation of the following decimal numbers, and convert to hexadecimal:

URL encoding uses hex code prefixed by %. Quoted Printable encoding uses hex code prefixed by =.

4-4 $; !< ) 74/ < ) 7477/ < -77+< > ) 749" 5! ) <047!<54! 0 = 0 %A7!47 9

Using SQL Queries in Crystal Reports

ECMAScript 3 rd Edition Compact Profile

SQL Injection Optimization and Obfuscation Techniques

Keywords are identifiers having predefined meanings in C programming language. The list of keywords used in standard C are : unsigned void

Structured vs. unstructured data. Semistructured data, XML, DTDs. Motivation for self-describing data

CSI 333 Lecture 1 Number Systems

Exchanger XML Editor - Canonicalization and XML Digital Signatures

I PUC - Computer Science. Practical s Syllabus. Contents

ASCII Characters. 146 CHAPTER 3 Information Representation. The sign bit is 1, so the number is negative. Converting to decimal gives

Performance Testing Web 2.0

03 - Lexical Analysis

C++ Language Tutorial

JAVASCRIPT AND COOKIES

CS106A, Stanford Handout #38. Strings and Chars

ECMA rd Edition / June Universal 3D File Format

Lecture 5: Java Fundamentals III

Oct: 50 8 = 6 (r = 2) 6 8 = 0 (r = 6) Writing the remainders in reverse order we get: (50) 10 = (62) 8

Transcription:

Ecma/TC39/2013/NN 4 th Draft ECMA-XXX 1 st Edition / July 2013 The JSON Data Interchange Format Reference number ECMA-123:2009 Ecma International 2009

COPYRIGHT PROTECTED DOCUMENT Ecma International 2013

Contents Page 1 Scope... 2 2 Conformance... 2 3 Normative references... 2 4 JSON Text... 2 5 JSON Values... 2 6 Objects... 3 7 Arrays... 3 8 Numbers... 4 9 String... 4 10 Security Considerations... 6 Ecma International 2013 i

Introduction JSON is a text format that facilitates structured data interchange between all programming languages. JSON is a syntax of braces, brackets, colons, and commas that is useful in many contexts, profiles, and applications. JSON was inspired by the object literals of JavaScript aka ECMAScript as defined in the ECMASCRIPT PROGRAMMING LANGUAGE STANDARD, THIRD EDITION. It does not attempt to impose ECMAScript s internal data representations on other programming languages. Instead, it shares a small subset of ECMAScript s textual representations with all other programming languages. JSON is agnostic about numbers. In any programming language, there can be a variety of number types of various capacities and complements, fixed or floating, binary or decimal. That can make interchange between different programming languages difficult. JSON instead offers only the representation of numbers that humans use: a sequence of digits. All programming languages know how to make sense of digit sequences even if they disagree on internal representations. That is enough to allow interchange. It is wise to encode JSON in Unicode, but JSON itself does not require that. JSON s only dependence on Unicode is in the hex numbers used in the \u escapement notation. JSON can be used with other character sets, and in contexts where there is no character encoding at all such as paper documents and marble monuments. Programming languages vary widely on whether they support objects, and if so, what characteristics and constraints the objects offer. The models of object systems can be wildly divergent and are continuing to evolve. JSON instead provides a simple notation for expressing collections of name/value pairs. Most programming languages will have some feature for representing such collections, which can go by names like record, struct, dict, map, hash, or object. JSON also provides support for ordered lists of values. All programming languages will have some feature for representing such lists, which can go by names like array, vector, or list. Because objects and arrays can nest, trees and other complex data structures can be represented. By accepting JSON s simple convention, complex data structures can be easily interchanged between incompatible programming languages. JSON does not support cyclic graphs, at least not directly. JSON is not indicated for applications requiring binary data. It is expected that other standards will refer to this one, strictly adhering to the JSON text format, while imposing restrictions on various encoding details. Such standards may require specific behaviours. JSON itself specifies no behaviour. Because it is so simple, it not expected that the JSON grammar will ever change. This gives JSON, as a foundational notation, tremendous stability. JSON was first presented to the world at the JSON.org website in 2001. JSON stands for JavaScript Object Notation. ii Ecma International 2013

This Ecma Standard has been adopted by the General Assembly of <month> <year>. Ecma International 2013 iii

"COPYRIGHT NOTICE 2013 Ecma International This document may be copied, published and distributed to others, and certain derivative works of it may be prepared, copied, published, and distributed, in whole or in part, provided that the above copyright notice and this Copyright License and Disclaimer are included on all such copies and derivative works. The only derivative works that are permissible under this Copyright License and Disclaimer are: (i) works which incorporate all or portion of this document for the purpose of providing commentary or explanation (such as an annotated version of the document), (ii) works which incorporate all or portion of this document for the purpose of incorporating features that provide accessibility, (iii) translations of this document into languages other than English and into different formats and (iv) works by making use of this specification in standard conformant products by implementing (e.g. by copy and paste wholly or partly) the functionality therein. However, the content of this document itself may not be modified in any way, including by removing the copyright notice or references to Ecma International, except as required to translate it into languages other than English or into a different format. The official version of an Ecma International document is the English language version on the Ecma International website. In the event of discrepancies between a translated version and the official version, the official version shall govern. The limited permissions granted above are perpetual and will not be revoked by Ecma International or its successors or assigns. This document and the information contained herein is provided on an "AS IS" basis and ECMA INTERNATIONAL DISCLAIMS ALL WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTY THAT THE USE OF THE INFORMATION HEREIN WILL NOT INFRINGE ANY OWNERSHIP RIGHTS OR ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE." iv Ecma International 2013

Ecma International 2013 v

The JSON Data Interchange Format 1 Scope JSON is a lightweight, text-based, language-independent data interchange format. It was derived from the ECMAScript Programming Language Standard, but is programming language independent. JSON defines a small set of formatting rules for the portable representation of structured data. 2 Conformance A conforming JSON generator or encoder will produce texts that strictly conform to the JSON grammar. 3 Normative references The following referenced documents are indispensable for the application of this document. For dated references, only the edition cited applies. For undated references, the latest edition of the referenced document (including any amendments) applies. ISO/IEC 10646, Information Technology Universal Coded Character Set (UCS) ECMA-262, The ECMAScript Programming Language, 3 th edition (December 1999) 4 JSON Text A JSON text is a sequence of tokens. The set of tokens includes six structural characters, strings, numbers, and three literal names. The six structural characters: { } [ ] :, Insignificant whitespace is allowed before or after any of the six structural characters. There are three literal names: true false null 5 JSON Values A JSON value can be an object, array, number, string, true, false, or null. Ecma International 2013

Figure 1 value 6 Objects An object structure is represented as a pair of curly brackets surrounding zero or more name/value pairs. A name is a string. A single colon comes after each name, separating the name from the value. A single comma separates a value from a following name. The order of the pairs is not significant. Figure 2 object 7 Arrays An array structure is represented as square brackets surrounding zero or more values. The values are separated by commas. The order of the values is significant. Ecma International 2009 All rights reserved

Figure 3 array 8 Numbers A number is represented in base 10 with no superfluous leading zero. It may have a preceding minus sign. It may have a.-prefixed fractional part. It may have an exponent of ten, prefixed by e or E and optionally + or -. Figure 4 number Numeric values that cannot be represented as sequences of digits (such as Infinity and NaN) are not permitted. 9 String The representation of strings is similar to conventions used in the C family of programming languages, a family that includes ECMAScript. A string is a sequence of characters wrapped with quotation marks. All characters may be placed within the quotation marks except for the characters that must be escaped: quotation mark, reverse solidus, and control characters. Ecma International 2013

There are two-character escape sequence representations of some characters. \" represents the quote character. \\ represents the reverse solidus character. \/ represents the solidus character. This makes it possible to embed JSON in HTML. \b represents the backspace character. \f represents the formfeed character. \n represents the new line or linefeed character. \r represents the carriage return character. \t represents the tab character. So, for example, a string containing only a single reverse solidus character may be represented as "\\". Any character may be represented as a hexadecimal number. The meaning of such a number is determined by ISO/IEC 10646. If the character is in the Basic Multilingual Plane (U+0000 through U+FFFF), then it may be represented as a six-character sequence: a reverse solidus, followed by the lowercase letter u, followed by four hexadecimal digits that encode the character's Unicode code point. The hexadecimal letters A though F can be upper or lowercase. So, for example, a string containing only a single reverse solidus character may be represented as "\u005c". The following four cases all produce the same result: "\u002f" "\u002f" "\/" "/" To escape an extended character that is not in the Basic Multilingual Plane, the character is represented as a twelve-character sequence, encoding the UTF-16 surrogate pair. So for example, a string containing only the G clef character (U+1D11E) may be represented as "\ud834\udd1e". Ecma International 2009 All rights reserved

" " \ " \ " \ / b f n r t u Figure 5 string 10 Security Considerations With any data format, it is important to encode correctly. Care must be taken when constructing JSON texts by concatenation. For example: account = 4627; comment = '","account":262'; // provided by attacker json_text = '{"account":' + account + ',"comment":"' + comment + '"}'; The result will be {"account":4627,"comment":"","account":262} which in some situations might be seen as being the same as {"comment":"","account":262} This confusion allows an attacker to modify the account property or any other property. Ecma International 2013

It is much wiser to use JSON libraries, which are available in many forms for most programming languages, to do the encoding, avoiding the confusion hazard. JSON is so similar to some programming languages that the native parsing ability of the language processors can be used to parse JSON texts. This should be avoided because the native parser will accept and execute code that is not JSON. For example, ECMAScript's eval() function is able parse JSON text, but is can also parse programs. If an attacker can inject code into the JSON text (as we saw above), then it can compromise the system. JSON decoders should always be used instead. The web browser's <script> tag is an alias for the eval() function. It should not be used to deliver JSON text to web browsers. Ecma International 2009 All rights reserved

Annex A (normative) JSON Object Grammar For Object object Meaningless whitespace may be inserted between any of these tokens to improve human readability. { } { members } members pair pair, members pair string : value Ecma International 2013

Annex B (normative) JSON Array Grammar Meaningless whitespace may be inserted between any of these tokens to improve human readability. array [ ] [ elements ] elements value value, elements Ecma International 2009 All rights reserved

Annex C (normative) JSON Value Grammar value string number object array true false null Ecma International 2013

Annex D (normative) JSON Grammar For Number number Whitespace may not be inserted into a number. int int frac int exp int frac exp int digit digit1-9 digits - digit - digit1-9 digits frac. digits exp e digits digits digit digit digits e e e+ e- E E+ E- Ecma International 2009 All rights reserved

digit1-9 1 2 3 4 5 6 7 8 9 digit 0 digit1-9 Ecma International 2013

Annex E (normative) JSON Grammar For String string Strings may not contain control characters. Spaces within a string are literal. " " " chars " chars char char chars char any-character-except-"-or-\-or-control-character \" \\ \/ \b \f \n \r \t \u hex hex hex hex hex digit a b c d e f Ecma International 2009 All rights reserved

A B C D E F Ecma International 2013