ჩვენს მოხალისეებს, ჯერ არ შეუმუშავებიათ ამ სტატიის ქართული ვარიანტი. შემოგვიერთდით და დაგვეხმარეთ გადათარგმნაში!
ამასთან, შეგიძლიათ იხილოთ სტატიის English (US) ვერსია.

The JSON object contains methods for parsing JavaScript Object Notation (JSON) and converting values to JSON. It can't be called or constructed, and aside from its two method properties, it has no interesting functionality of its own.

JavaScript and JSON differences

JSON is a syntax for serializing objects, arrays, numbers, strings, booleans, and null. It is based upon JavaScript syntax but is distinct from it: some JavaScript is not JSON.

Objects and Arrays: Property names must be double-quoted strings; trailing commas are forbidden.

Numbers: Leading zeros are prohibited (in JSON.stringify zeros will be ignored, but in JSON.parse it will throw SyntaxError); a decimal point must be followed by at least one digit.

Any JSON text is a valid JavaScript expression – but only in JavaScript engines that have implemented the proposal to make all JSON text valid ECMA-262. In engines that haven't implemented the proposal, U+2028 LINE SEPARATOR and U+2029 PARAGRAPH SEPARATOR are allowed in string literals and property keys in JSON; but their use in these features in JavaScript literals is a SyntaxError.

Consider this example where JSON.parse() parses the string as JSON and eval executes the string as JavaScript:

var code = '"\u2028\u2029"';
JSON.parse(code); // evaluates to "\u2028\u2029" in all engines
eval(code); // throws a SyntaxError in old engines

Full JSON syntax

The full JSON syntax is as follows:

JSON = null
    or true or false
    or JSONNumber
    or JSONString
    or JSONObject
    or JSONArray

JSONNumber = - PositiveNumber
          or PositiveNumber
PositiveNumber = DecimalNumber
              or DecimalNumber . Digits
              or DecimalNumber . Digits ExponentPart
              or DecimalNumber ExponentPart
DecimalNumber = 0
             or OneToNine Digits
ExponentPart = e Exponent
            or E Exponent
Exponent = Digits
        or + Digits
        or - Digits
Digits = Digit
      or Digits Digit
Digit = 0 through 9
OneToNine = 1 through 9

JSONString = ""
          or " StringCharacters "
StringCharacters = StringCharacter
                or StringCharacters StringCharacter
StringCharacter = any character
                  except " or \ or U+0000 through U+001F
               or EscapeSequence
EscapeSequence = \" or \/ or \\ or \b or \f or \n or \r or \t
              or \u HexDigit HexDigit HexDigit HexDigit
HexDigit = 0 through 9
        or A through F
        or a through f

JSONObject = { }
          or { Members }
Members = JSONString : JSON
       or Members , JSONString : JSON

JSONArray = [ ]
         or [ ArrayElements ]
ArrayElements = JSON
             or ArrayElements , JSON

Insignificant whitespace may be present anywhere except within a JSONNumber (numbers must contain no whitespace) or JSONString (where it is interpreted as the corresponding character in the string, or would cause an error). The tab character (U+0009), carriage return (U+000D), line feed (U+000A), and space (U+0020) characters are the only valid whitespace characters.

Methods

JSON.parse()
Parse a string as JSON, optionally transform the produced value and its properties, and return the value.
JSON.stringify()
Return a JSON string corresponding to the specified value, optionally including only certain properties or replacing property values in a user-defined manner.

Specifications

Specification Status Comment
ECMAScript 5.1 (ECMA-262)
The definition of 'JSON' in that specification.
Standard Initial definition.
ECMAScript 2015 (6th Edition, ECMA-262)
The definition of 'JSON' in that specification.
Standard  
ECMAScript Latest Draft (ECMA-262)
The definition of 'JSON' in that specification.
Draft  

Browser compatibility

Update compatibility data on GitHub
DesktopMobileServer
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidiOS SafariSamsung InternetNode.js
Basic supportChrome Full support YesEdge Full support YesFirefox Full support 3.5IE Full support 8Opera Full support 10.5Safari Full support 4WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support Yes
parseChrome Full support YesEdge Full support YesFirefox Full support 3.5IE Full support 8Opera Full support 10.5Safari Full support 4WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support Yes
stringifyChrome Full support YesEdge Full support YesFirefox Full support 3.5IE Full support 8Opera Full support 10.5Safari Full support 4WebView Android Full support YesChrome Android Full support YesEdge Mobile Full support YesFirefox Android Full support 4Opera Android Full support YesSafari iOS Full support YesSamsung Internet Android Full support Yesnodejs Full support Yes
JavaScript is a superset of JSONChrome Full support 66Edge No support NoFirefox Full support 62IE No support NoOpera Full support 53Safari Full support YesWebView Android Full support 66Chrome Android Full support 66Edge Mobile No support NoFirefox Android Full support 62Opera Android Full support 53Safari iOS Full support YesSamsung Internet Android No support Nonodejs Full support 10.0.0

Legend

Full support  
Full support
No support  
No support

See also

დოკუმენტების ჭდეები და წვლილის შემტანები

ჭდეები: 
ამ გვერდის შექმნაში, წვლილის შემტანები: fscholz, xfq, marumari, GijsKruitbosch, Dveditz, utkarshbhatt12, DekusDenial, mfluehr, jameshkramer, Ende93, bekti, MexieAndCo, markokr, Mingun, Sheppy, jswisher, ethertank, ziyunfei, fusionchess, outis, Rob W, evilpie, trevorh, Waldo
ბოლო განახლების ავტორი: fscholz,