JSON

From MobileRead
Jump to: navigation, search

JSON, JavaScript Object Notation, is syntax for storing and exchanging text information. Much like XML. JSON is smaller than XML, and faster and easier to parse. It can be an executed as well.

Contents

[edit] Overview

From http://json.org

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language, Standard ECMA-262 3rd Edition - December 1999. JSON is a text format that is completely language independent but uses conventions that are familiar to programmers of the C-family of languages, including C, C++, C#, Java, JavaScript, Perl, Python, and many others. These properties make JSON an ideal data-interchange language.

[edit] Introduction

JSON is built on two structures

  • An object is an unordered set of name/value pairs. An object begins with { (left brace) and ends with } (right brace). Each name is followed by : (colon) and the name/value pairs are separated by , (comma).
  • An array is an ordered collection of values. An array begins with [ (left bracket) and ends with ] (right bracket). Values are separated by , (comma).

A name is a string.

A value can be a string in double quotes, or a number, or true or false or null, or an object or an array. These structures can be nested.

A string can be any unicode value except \, ", or control characters. The \ can be used to escape the normal meaning of these exception characters to include them in a string.

[edit] Example

From wikipedia - An object that describes a person

{
    "firstName": "John",
    "lastName": "Smith",
    "age": 25,
    "address": {
        "streetAddress": "21 2nd Street",
        "city": "New York",
        "state": "NY",
        "postalCode": 10021
    },
    "phoneNumbers": [
        {
            "type": "home",
            "number": "212 555-1234"
        },
        {
            "type": "fax",
            "number": "646 555-4567"
        }
    ]
}

[edit] Usage

JSON is supported by most Web Browsers and HTML5. It can be used in place of JavaScripts. JSON is used in KF8 for a few things and in AZK most structure on Kindle devices and software.

[edit] JSON-LD

The syntax is designed to easily integrate into deployed systems that already use JSON, and provides a smooth upgrade path from JSON to JSON-LD. It is primarily intended to be a way to use "Linked Data" in Web-based programming environments, to build interoperable Web services, and to store Linked Data in JSON-based storage engines.

[edit] For more information

Personal tools
Namespaces

Variants
Actions
Navigation
MobileRead Networks
Toolbox