| <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> |
| <html> |
| <head> |
| <title>JSON - Preferred Marshaling</title> |
| </head> |
| <body lang='EN-US'> |
| |
| <h1>JSON - Preferred Marshaling</h1> |
| |
| <p>The TCF message data format is service specific. Since service specifications are |
| separate from the protocol specification, a service designer can choose any data format that |
| suits the service requirements best. However, to promote better compatibility and to |
| simplify service design and implementation, we recommend using <b>JSON</b> for data formatting.</p> |
| |
| <p><b>JSON</b> (pronounced like the |
| English given name <i>Jason</i>), which stands for "<b>J</b>ava<b>S</b>cript <b>O</b>bject |
| <b>N</b>otation", is a lightweight, text-based, language-independent computer data |
| interchange format. <b>JSON</b> is a subset of the object literal notation of JavaScript |
| but its use does not require JavaScript.</p> |
| |
| <p><b>JSON</b> represents data with the same basic types that programming languages |
| use. <b>JSON</b>'s basic types are:</p> |
| |
| <ul type='disc'> |
| <li>Number (integer, real, or floating-point) |
| |
| <li>String (double-quoted with backslash escapement) |
| |
| <li>Boolean (<code>true</code> and <code>false</code>) |
| |
| <li>Array (an ordered sequence of values) |
| |
| <li>Object (collection of key/value pairs) |
| |
| <li><code>null</code> |
| </ul> |
| |
| <p>The structures used in most programming languages easily map directly onto JSON's |
| structures, and back again.</p> |
| |
| <p>JSON maps data onto Unicode string. Then the string is mapped onto array of bytes |
| using UTF-8 encoding.</p> |
| |
| <p>JSON specification:</p> |
| |
| <pre><b><font face="Courier New" size=2 color=#333399> |
| <i><object></i> |
| ⇒ {} |
| ⇒ { <i><members></i> } |
| |
| <i><members></i> |
| ⇒ <i><string></i> : <i><value></i> |
| ⇒ <i><members></i> , <i><string></i> : <i><value></i> |
| |
| <i><array></i> |
| ⇒ [] |
| ⇒ [ <i><elements></i> ] |
| |
| <i><elements></i> |
| ⇒ <i><value></i> |
| ⇒ <i><elements</i>> , <i><value></i> |
| |
| <i><value></i> |
| ⇒ <i><string></i> |
| ⇒ <i><number></i> |
| ⇒ <i><object></i> |
| ⇒ <i><array></i> |
| ⇒ <i><boolean></i> |
| ⇒ null |
| |
| <i><boolean></i> |
| ⇒ true |
| ⇒ false |
| |
| <i><string></i> |
| ⇒ "" |
| ⇒ " <i><chars></i> " |
| |
| <i><chars></i> |
| ⇒ <i><char></i> |
| ⇒ <i><chars> <char></i> |
| |
| <i><char</i>> |
| ⇒ <i><any Unicode except " or \ or control></i> |
| ⇒ \"<i></i> |
| ⇒ \\<i></i> |
| ⇒ \/<i></i> |
| ⇒ \b<i></i> |
| ⇒ \f<i></i> |
| ⇒ \n<i></i> |
| ⇒ \r<i></i> |
| ⇒ \t<i></i> |
| ⇒ \u <i><four-hex-digits></i> |
| |
| <i><number</i>> |
| ⇒ <i><int></i> |
| ⇒ <<i>int> <fraction></i> |
| ⇒ <<i>int> <exponent></i> |
| ⇒ <<i>int> <fraction> <exponent></i> |
| |
| <i><int></i> |
| ⇒ <i><digit></i> |
| ⇒ <<i>digit 1-9> <digits></i> |
| ⇒ - <<i>digit></i> |
| ⇒ - <<i>digit 1-9> <digits</i>> |
| |
| <i><fraction></i> |
| ⇒ . <i><digits></i> |
| |
| <i><exponent></i> |
| ⇒ <i><e></i> <i><digits></i> |
| |
| <i><digits></i> |
| ⇒ <i><digit></i> |
| ⇒ <<i>digits></i> <<i>digit></i> |
| |
| <i><e></i> |
| ⇒ e |
| ⇒ e+ |
| ⇒ e- |
| ⇒ E |
| ⇒ E+ |
| ⇒ E- |
| |
| </font></b></pre> |
| |
| <p>See <a href='http://www.json.org/'>www.json.org</a> for more details.</p> |
| |
| <h2><a name='JSONExamples'>Examples</a></h2> |
| |
| <p>This is a JSON array containing two objects:</p> |
| |
| <pre> |
| [ |
| { |
| "Precision": "zip", |
| "Latitude": 37.7668, |
| "Longitude": -122.3959, |
| "City": "SAN FRANCISCO", |
| "State": "CA", |
| "Zip": "94107", |
| "Country": "US" |
| }, |
| { |
| "Precision": "zip", |
| "Latitude": 37.371991, |
| "Longitude": -122.026020, |
| "City": "SUNNYVALE", |
| "State": "CA", |
| "Zip": "94085", |
| "Country": "US" |
| } |
| ] |
| </pre> |
| |
| </body> |
| </html> |