Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
JSON
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
=== Character encoding === Although Crockford originally asserted that JSON is a strict subset of [[JavaScript]] and [[ECMAScript]],<ref>{{cite web|url=http://www.json.org/js.html |title=JSON in JavaScript |date=2016-07-10 |access-date=2016-08-13 |author=Douglas Crockford |url-status=dead |archive-url=https://web.archive.org/web/20160710230817/http://www.json.org/js.html |archive-date=2016-07-10 |quote=JSON is a subset of the object literal notation of JavaScript. }}</ref> his specification actually allows valid JSON documents that are not valid JavaScript; JSON allows the [[Unicode#Newlines|Unicode line terminators]] {{unichar|2028|LINE SEPARATOR}} and {{unichar|2029|PARAGRAPH SEPARATOR}} to appear unescaped in quoted strings, while ECMAScript 2018 and older do not.<ref name="json-2028">{{cite web|url=http://timelessrepo.com/json-isnt-a-javascript-subset|title=JSON: The JavaScript subset that isn't|author=Holm, Magnus|date=15 May 2011|publisher=The timeless repository|access-date=23 September 2016|archive-date=May 13, 2012|archive-url=https://web.archive.org/web/20120513012409/http://timelessrepo.com/json-isnt-a-javascript-subset|url-status=dead}}</ref><ref name=ECMATC39/> This is a consequence of JSON disallowing only "control characters". For maximum portability, these characters are backslash-escaped. JSON exchange in an open ecosystem must be encoded in [[UTF-8]].<ref name="rfc8259">{{cite journal | url=https://tools.ietf.org/html/rfc8259 | title= The JavaScript Object Notation (JSON) Data Interchange Format | publisher=IETF | date= December 2017 | doi= 10.17487/RFC8259 | access-date=16 February 2018| editor-last1= Bray | editor-first1= T | last1= Bray | first1= T. | s2cid= 263868313 }}</ref> The encoding supports the full Unicode character set, including those characters outside the [[Basic Multilingual Plane]] (U+0000 to U+FFFF). However, if escaped, those characters must be written using [[UTF-16#Code points from U+010000 to U+10FFFF|UTF-16 surrogate pairs]]. For example, to include the [[Emoji]] character {{unichar|1F610|NEUTRAL FACE}} in JSON: <syntaxhighlight lang="javascript"> { "face": "π" } // or { "face": "\uD83D\uDE10" } </syntaxhighlight> JSON became a strict subset of ECMAScript as of the language's 2019 revision.<ref name=ECMATC39/><ref name=ECMATC39Stage4/>
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)