JSON/pl

This is an old revision of JSON/pl, edited by Slawek at . The current revision is 137919.

/* JSON Object */ tłumaczenie na j. polski

Przegląd

JSON (JavaScript Object Notation) jest to znormalizowany format wymiany danych zapisanych przy użyciu prostego tekstu. Jak sama nazwa wskazuje, jest oparty na podstawie języka programowania JavaScript; jest jednak całkowicie niezależny od języka. Oprócz tego, że ludzie mogą go łatwo czytać i pisać pliki JSON, to maszyny również są w stanie parsować i generować te pliki.

W porównaniu z XML, jest bardziej czytelny dla człowieka.

Obiekt JSON

Obiekt JSON to nic innego jak zbiór oddzielonych przecinkami par nazwa/wartość (często nazywanych elementami) ujętych w nawiasy klamrowe:

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

Aby ułatwić ludziom czytanie i wizualizację, par nazwa/wartość są one często wymienione pionowo:

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

Nazwa jest łańcuchem znaków ujętych w podwójnych cudzysłowach, a wartością może być jedna z następujących opcji:

Obiekty JSON można zawsze zagnieżdżać dowolnie, aby tworzyć jeszcze bardziej złożone obiekty:

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

Sprawdź ten link, aby wyodrębnić informacje, gdy masz kilku użytkowników.

Valid JSON format

There are a few rules and guidelines that define the JSON syntax (see RFC 4627):

Implementations

JSON implementation is not very strict, and a lot of leeway is granted to the client application and/or parser to enforce the guidelines. As usual when writing code:

There are two main implementations of JSON:

The official JSON Specification syntax

This implementation adheres strictly to the RFC 4627 guidelines above and does not allow deviation from the specification.

The Javascript syntax

This implementation 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"],}

See also

{{#if:{{PROTECTIONEXPIRY:edit|{{{Link|}}}}} |'''[[:{{{Link}}}|{{{Caption}}}]]''' │ }}