Project:VisualEditor testing/TestingRefs

Hello

Hello, world!

History
Douglas Crockford was the first to specify and popularize the JSON format.

JSON was used at State Software Inc., a company co-founded by Crockford, starting in April 2001, and funded by Tesla Ventures. When State was founded in early 2001 by six former employees of Communities.com, they agreed to build a system that used standard browser capabilities and provided an abstraction layer for Web developers to create stateful Web applications that had a persistent duplex connection to a Web server by holding the two http connections open and recycling them before standard browser time-outs if no further data were exchanged. The idea for the State Application Framework was developed by Chip Morningstar at State Software. It was used in a project at Communities.com for Cartoon Network, which used a plug-in with a proprietary messaging format to manipulate DHTML elements (this system is also owned by 3DO). Upon discovery of early AJAX capabilities, digiGroups, Noosh, and others used frames to pass information into the user browsers' visual field without refreshing a Web application's visual context, realizing real-time rich Web applications using only the standard HTTP, HTML and JavaScript capabilities of Netscape 4.0.5+ and IE 5+. Douglas Crockford then found that JavaScript could be used as an object-based messaging format for such a system. The system was sold to Sun Microsystems, Amazon.com and EDS. The JSON.org Web site was launched in 2002. In December 2005, Yahoo! began offering some of its Web services in JSON. Google started offering JSON feeds for its GData web protocol in December 2006.

Although JSON was originally based on a non-strict subset of the JavaScript scripting language (specifically, Standard ECMA-262 3rd Edition—December 1999 ) and is commonly used with that language, it is a language-independent data format. Code for parsing and generating JSON data is readily available for a large variety of programming languages. JSON's Web site provides a comprehensive listing of existing JSON libraries, organized by language.

Data types, syntax and example
JSON's basic types are:


 * Number (double precision in JavaScript, generally depends on implementation)
 * String (double-quoted en:Unicode, with backslash escaping)
 * Boolean ( or  )
 * Array (an ordered sequence of values, comma-separated and enclosed in square brackets; the values do not need to be of the same type)
 * Object (an unordered collection of key:value pairs with the ':' character separating the key and the value, comma-separated and enclosed in curly braces; the keys must be strings and should be distinct from each other)
 * (empty)

Non-significant white space may be added freely around the "structural characters" (i.e. braces "{ }", brackets "[ ]", colons ":" and commas ",").

The following example shows the JSON representation of an object that describes a person. The object has string fields for first name and last name, a number field for age, an object representing the person's address and an array of phone number objects.

One potential pitfall of the free-form nature of JSON comes from the ability to write numbers as either numeric literals or quoted strings. For example, ZIP Codes in the northeastern U.S. begin with zeroes (for example, 07728 for Freehold, New Jersey). If written with quotes by one programmer but not by another, the leading zero could be dropped when exchanged between systems, when searched for within the same system, or when printed. In addition, postal codes in the U.S. are numbers but other countries use letters as well. This is a type of problem that the use of a JSON Schema (see below) is intended to reduce.

Since JSON is almost a subset of JavaScript, it is possible, but not recommended, to parse most JSON text into an object by invoking JavaScript's  function. For example, if the above JSON data is contained within a JavaScript string variable, one could use it to create the JavaScript object   as follows:

The  variable must be wrapped in parentheses to avoid an ambiguity in JavaScript's syntax.

The recommended way, however, is to use a JSON en:parser. Unless a client absolutely trusts the source of the text, or must parse and accept text that is not strictly JSON-compliant, one should avoid. A correctly implemented JSON parser accepts only valid JSON, preventing potentially malicious code from being executed inadvertently.

Browsers, such as Firefox 4 and Internet Explorer 8, include special features for parsing JSON. As native browser support is more efficient and secure than, native JSON support is included in the recently-released Edition 5 of the ECMAScript standard.

Despite the widespread belief that JSON is a JavaScript subset, this is not the case. Specifically, JSON allows the Unicode line terminators LINE SEPARATOR and PARAGRAPH SEPARATOR to appear unescaped in quoted strings, while JavaScript does not. This is a consequence of JSON disallowing only "control characters". This subtlety is important when generating en:JSONP.

Unsupported native data types
JavaScript syntax defines several native data types that are not included in the JSON standard: Date, Error, Regular Expression, and Function. These JavaScript data types must be represented as some other data format, with the programs on both ends agreeing on how to convert between the types. As of 2011, there are some de facto standards for e.g. converting between Date and String, but none universally recognized. Other languages may have a different set of native types that must be serialized carefully to deal with this type of conversion.

Schema
JSON Schema is a specification for a JSON-based format for defining the structure of JSON data. JSON Schema provides a contract for what JSON data is required for a given application and how it can be modified. JSON Schema is intended to provide validation, documentation, and interaction control of JSON data. JSON Schema is based on the concepts from XML Schema, RelaxNG, and Kwalify, but is intended to be JSON-based, so that JSON data in the form of a schema can be used to validate JSON data, the same serialization/deserialization tools can be used for the schema and data, and it can be self descriptive.

JSON Schema is written up as an en:Internet-Draft, currently version 4. There are several validators currently available for different programming languages, each with varying levels of conformance.

Example JSON Schema:

The JSON Schema above can be used to test the validity of the JSON code below:

MIME type
The official en:MIME type for JSON text is " ".