Sign in Join
Wiki copytemporary

JSON/ja

한국어 · English · Polski · Suomi · Русский · 中文(中国) · 日本語

概要

JSON (JavaScript Object Notation) は、簡単なテキストファイルを用いたデータ交換用の保存形式です。 JSONは、名前から分かるように JavaScript のオブジェクト表記法に基づいていますが JavaScript 専用ではありません。 人間による読み書きも簡単にでき、機械(パソコン)にとってもパースや生成が容易な形式です。

XMLと比較しても、より人間にとって読みやすい形式になっています。

JSON オブジェクト

JSON オブジェクトは、カンマ(,)で区切られた name/value の一対(メンバと呼びます)を、波括弧(なみかっこ; curly bracket: {})で括った集まりです。:

javascript
{"name1":value1, "name2":value2 ...}

上記は、可読性を高めるために、しばしば縦に name/value を表記するときもあります。:

javascript
{
    "name1": value1,
    "name2": value2
}

name は、2重引用符(ダブルクォート; double quote: "")に囲まれた文字列の形をとります。対して、valueは以下に示す表記が可能です。:

JSON オブジェクトは、さらに複雑なオブジェクトを表現するために、どんどんネストする(入れ子にする)ことができます。:

javascript
{"user":
    {   "userid": 1900,
        "username": "jsmith",
        "password": "secret",
        "groups": [ "admins", "users", "maintainers"]
    }
}

正しい JSON 形式

JSON 形式の定義は、2、3のガイドラインとルールからなります。(RFC 4627 を参照):

実装

JSON の実装は厳密なものではありません。 クライアント側の実装には を許し、一方で パーサーはガイドラインに従うように実装しています。通常のコードを書く場合は、and a lot of leeway is granted to the client application and/or parser to enforce the guidelines. As usual when writing code:

JSONには、2つの主流となる実装があります。:

公式の JSON 形式

この実装は、This implementation adheres strictly to the RFC 4627 guidelines above and does not allow deviation from the specification.

Javascript 形式

この実装は、follows the implementation of the Javascript programming language and as such allows for a few deviations from the official specification. For example:

  1. allows un-quoted keys eg {name: "John Doe" }
  2. allows single quotes for keys and/or string values; and a liberal mix of single and double quotes eg {'name': "John Doe", "language":'Pascal'}
  3. allows trailing comma after the last member of an array and/or object eg {"keywords":["if","begin","for",], "IDEs":["Lazarus","fpIDE","MSEide"],}

関連情報


From the Free Pascal wiki, page "JSON/ja", as it stood on 2017-05-04 after a change by Miyatakejiro, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 1, last changed by WikiArchive .

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.