RFC8259 8259
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +61 -0
- data/.rspec +4 -0
- data/.yardopts +2 -0
- data/Gemfile +58 -0
- data/LICENSE.txt +40 -0
- data/README.txt +1 -0
- data/RFC8259 +899 -0
- data/RFC8259.gemspec +89 -0
- data/Rakefile +86 -0
- data/lib/RFC8259.rb +94 -0
- data/lib/RFC8259/array.rb +136 -0
- data/lib/RFC8259/dumper.rb +255 -0
- data/lib/RFC8259/false.rb +79 -0
- data/lib/RFC8259/null.rb +79 -0
- data/lib/RFC8259/number.rb +149 -0
- data/lib/RFC8259/object.rb +137 -0
- data/lib/RFC8259/parser.ry +275 -0
- data/lib/RFC8259/string.rb +226 -0
- data/lib/RFC8259/true.rb +79 -0
- data/lib/RFC8259/value.rb +96 -0
- data/lib/RFC8259/version.rb +46 -0
- data/spec/RFC8259_spec.rb +305 -0
- data/spec/acceptance/README.txt +66 -0
- data/spec/acceptance/invalid/0001-ws/0001-verical-tab.txt +1 -0
- data/spec/acceptance/invalid/0001-ws/0002-null.txt +0 -0
- data/spec/acceptance/invalid/0001-ws/0003-space-in-number-1.txt +1 -0
- data/spec/acceptance/invalid/0001-ws/0004-space-in-number-2.txt +1 -0
- data/spec/acceptance/invalid/0001-ws/0005-space-in-number-3.txt +1 -0
- data/spec/acceptance/invalid/0001-ws/0006-space-in-number-4.txt +1 -0
- data/spec/acceptance/invalid/0001-ws/0007-space-in-number-5.txt +1 -0
- data/spec/acceptance/invalid/0001-ws/0008-space-in-number-6.txt +1 -0
- data/spec/acceptance/invalid/0001-ws/0009-space-in-literal.txt +1 -0
- data/spec/acceptance/invalid/0001-ws/0010-Unicode-LINE_SEPARATOR.txt +1 -0
- data/spec/acceptance/invalid/0002-comments/0001-C-style.txt +1 -0
- data/spec/acceptance/invalid/0002-comments/0002-C-plusplus-style.txt +2 -0
- data/spec/acceptance/invalid/0002-comments/0003-sh-style.txt +2 -0
- data/spec/acceptance/invalid/0002-comments/0004-python-docstring.txt +3 -0
- data/spec/acceptance/invalid/0002-comments/0005-SQL-style.txt +2 -0
- data/spec/acceptance/invalid/0002-comments/0006-BASIC-style.txt +2 -0
- data/spec/acceptance/invalid/0003-literals/0001-FALSE.txt +1 -0
- data/spec/acceptance/invalid/0003-literals/0002-NULL.txt +1 -0
- data/spec/acceptance/invalid/0003-literals/0003-TRUE.txt +1 -0
- data/spec/acceptance/invalid/0003-literals/0004-NUL.txt +1 -0
- data/spec/acceptance/invalid/0003-literals/0005-nil.txt +1 -0
- data/spec/acceptance/invalid/0003-literals/0006-undef.txt +1 -0
- data/spec/acceptance/invalid/0003-literals/0007-modifier.txt +1 -0
- data/spec/acceptance/invalid/0003-literals/0008-undefined.txt +1 -0
- data/spec/acceptance/invalid/0004-numbers/0001-omit-zero.txt +1 -0
- data/spec/acceptance/invalid/0004-numbers/0002-minus-dot.txt +1 -0
- data/spec/acceptance/invalid/0004-numbers/0003-missing-frac.txt +1 -0
- data/spec/acceptance/invalid/0004-numbers/0004-missing-exp.txt +1 -0
- data/spec/acceptance/invalid/0004-numbers/0005-octal.txt +1 -0
- data/spec/acceptance/invalid/0004-numbers/0006-hexadecimal.txt +1 -0
- data/spec/acceptance/invalid/0004-numbers/0007-comma.txt +1 -0
- data/spec/acceptance/invalid/0004-numbers/0008-perl-underscore.txt +1 -0
- data/spec/acceptance/invalid/0004-numbers/0009-NaN.txt +1 -0
- data/spec/acceptance/invalid/0004-numbers/0010-Inf.txt +1 -0
- data/spec/acceptance/invalid/0004-numbers/0011-Infinity.txt +1 -0
- data/spec/acceptance/invalid/0005-strings/0000-NUL.txt +0 -0
- data/spec/acceptance/invalid/0005-strings/0001-not-terminated.txt +1 -0
- data/spec/acceptance/invalid/0005-strings/0002-single-quote.txt +1 -0
- data/spec/acceptance/invalid/0005-strings/0003-back-quote.txt +1 -0
- data/spec/acceptance/invalid/0005-strings/0004-carriage-return.txt +1 -0
- data/spec/acceptance/invalid/0005-strings/0005-line-feed.txt +2 -0
- data/spec/acceptance/invalid/0005-strings/0006-unknown-escape-a.txt +1 -0
- data/spec/acceptance/invalid/0005-strings/0007-unknown-escape-perl-style.txt +1 -0
- data/spec/acceptance/invalid/0005-strings/0008-unknown-escape-C-style.txt +1 -0
- data/spec/acceptance/invalid/0005-strings/0009-unknown-escape-ruby-style.txt +1 -0
- data/spec/acceptance/invalid/0005-strings/0010-escape-too-short.txt +1 -0
- data/spec/acceptance/invalid/0005-strings/0011-C-string-concat.txt +1 -0
- data/spec/acceptance/invalid/0005-strings/0012-perl-string-concat.txt +1 -0
- data/spec/acceptance/invalid/0005-strings/0013-Java-string-concat.txt +1 -0
- data/spec/acceptance/invalid/0006-encodings/0001-CESU-8.txt +1 -0
- data/spec/acceptance/invalid/0006-encodings/0002-Windows-31J.txt +1 -0
- data/spec/acceptance/invalid/0006-encodings/0003-EBCDIC.txt +1 -0
- data/spec/acceptance/invalid/0006-encodings/0004-overlong-utf8.txt +1 -0
- data/spec/acceptance/invalid/0007-arrays/0001-lacks-open.txt +1 -0
- data/spec/acceptance/invalid/0007-arrays/0002-lacks-close.txt +1 -0
- data/spec/acceptance/invalid/0007-arrays/0003-interleaving-parens.txt +1 -0
- data/spec/acceptance/invalid/0007-arrays/0004-dangling-comma.txt +1 -0
- data/spec/acceptance/invalid/0007-arrays/0005-missing-comma.txt +1 -0
- data/spec/acceptance/invalid/0007-arrays/0006-colon-instead-of-comma.txt +1 -0
- data/spec/acceptance/invalid/0008-hashes/0001-key-missing.txt +1 -0
- data/spec/acceptance/invalid/0008-hashes/0002-value-missing.txt +1 -0
- data/spec/acceptance/invalid/0008-hashes/0003-true-key.txt +1 -0
- data/spec/acceptance/invalid/0008-hashes/0004-false-key.txt +1 -0
- data/spec/acceptance/invalid/0008-hashes/0005-null-key.txt +1 -0
- data/spec/acceptance/invalid/0008-hashes/0006-numeric-key.txt +1 -0
- data/spec/acceptance/invalid/0008-hashes/0007-array-key.txt +1 -0
- data/spec/acceptance/invalid/0008-hashes/0008-hash-key.txt +1 -0
- data/spec/acceptance/invalid/0008-hashes/0009-key-not-escaped.txt +4 -0
- data/spec/acceptance/invalid/0009-javascriptisms/0001-JSONP.txt +1 -0
- data/spec/acceptance/invalid/0009-javascriptisms/0002-new-Array.txt +3 -0
- data/spec/acceptance/invalid/0009-javascriptisms/0003-new-Date.txt +1 -0
- data/spec/acceptance/invalid/0009-javascriptisms/0004-new-Error.txt +1 -0
- data/spec/acceptance/invalid/0009-javascriptisms/0005-Math.txt +1 -0
- data/spec/acceptance/invalid/0009-javascriptisms/0006-regular-expression.txt +1 -0
- data/spec/acceptance/invalid/0009-javascriptisms/0007-function.txt +7 -0
- data/spec/acceptance/invalid/0009-javascriptisms/0008-this.txt +1 -0
- data/spec/acceptance/invalid/0009-javascriptisms/0009-plusplus.txt +3 -0
- data/spec/acceptance/invalid/0009-javascriptisms/0010-ternary-operator.txt +1 -0
- data/spec/acceptance/valid/0001-ws/0001-space.json +1 -0
- data/spec/acceptance/valid/0001-ws/0002-tab.json +1 -0
- data/spec/acceptance/valid/0001-ws/0003-lf.json +1 -0
- data/spec/acceptance/valid/0001-ws/0004-cr.json +1 -0
- data/spec/acceptance/valid/0001-ws/0005-before.json +1 -0
- data/spec/acceptance/valid/0001-ws/0006-after.json +1 -0
- data/spec/acceptance/valid/0001-ws/0007-around-comma.json +3 -0
- data/spec/acceptance/valid/0001-ws/0008-around-colon.json +3 -0
- data/spec/acceptance/valid/0002-bare-values/0001-false.json +1 -0
- data/spec/acceptance/valid/0002-bare-values/0002-null.json +1 -0
- data/spec/acceptance/valid/0002-bare-values/0003-true.json +1 -0
- data/spec/acceptance/valid/0002-bare-values/0004-number.json +1 -0
- data/spec/acceptance/valid/0002-bare-values/0005-string.json +1 -0
- data/spec/acceptance/valid/0003-literals/0001-false.json +1 -0
- data/spec/acceptance/valid/0003-literals/0002-null.json +1 -0
- data/spec/acceptance/valid/0003-literals/0003-true.json +1 -0
- data/spec/acceptance/valid/0004-numbers/0000-zero.json +1 -0
- data/spec/acceptance/valid/0004-numbers/0001-one.json +1 -0
- data/spec/acceptance/valid/0004-numbers/0002-two.json +1 -0
- data/spec/acceptance/valid/0004-numbers/0003-three.json +1 -0
- data/spec/acceptance/valid/0004-numbers/0004-four.json +1 -0
- data/spec/acceptance/valid/0004-numbers/0005-five.json +1 -0
- data/spec/acceptance/valid/0004-numbers/0006-six.json +1 -0
- data/spec/acceptance/valid/0004-numbers/0007-seven.json +1 -0
- data/spec/acceptance/valid/0004-numbers/0008-eight.json +1 -0
- data/spec/acceptance/valid/0004-numbers/0009-nine.json +1 -0
- data/spec/acceptance/valid/0004-numbers/0010-ten.json +1 -0
- data/spec/acceptance/valid/0004-numbers/0011-minus.json +1 -0
- data/spec/acceptance/valid/0004-numbers/0012-fraction.json +1 -0
- data/spec/acceptance/valid/0004-numbers/0013-exponent.json +1 -0
- data/spec/acceptance/valid/0004-numbers/0014-exponent-minus.json +1 -0
- data/spec/acceptance/valid/0004-numbers/0015-exponent-plus.json +1 -0
- data/spec/acceptance/valid/0004-numbers/0016-complex.json +1 -0
- data/spec/acceptance/valid/0004-numbers/0017-DBL_MAX.json +1 -0
- data/spec/acceptance/valid/0004-numbers/0018-DBL_MIN.json +1 -0
- data/spec/acceptance/valid/0004-numbers/0019-subnormal-number.json +1 -0
- data/spec/acceptance/valid/0004-numbers/0020-1E400.json +1 -0
- data/spec/acceptance/valid/0004-numbers/0021-pi.json +1 -0
- data/spec/acceptance/valid/0004-numbers/0022-UINT32_MAX.json +1 -0
- data/spec/acceptance/valid/0004-numbers/0023-UINT64_MAX.json +1 -0
- data/spec/acceptance/valid/0004-numbers/0024-INT64_MIN.json +1 -0
- data/spec/acceptance/valid/0004-numbers/0025-high-resolution-zero.json +1 -0
- data/spec/acceptance/valid/0004-numbers/0026-high-resolution-100.json +1 -0
- data/spec/acceptance/valid/0005-strings/0001-empty.json +1 -0
- data/spec/acceptance/valid/0005-strings/0002-basic-latin.json +1 -0
- data/spec/acceptance/valid/0005-strings/0003-escapes.json +1 -0
- data/spec/acceptance/valid/0005-strings/0004-raw-unicode.json +1 -0
- data/spec/acceptance/valid/0005-strings/0005-escaped-unicode.json +1 -0
- data/spec/acceptance/valid/0005-strings/0006-escaped-NUL.json +1 -0
- data/spec/acceptance/valid/0005-strings/0007-escaped-invalid-unicode-still-valid-as-json.json +1 -0
- data/spec/acceptance/valid/0005-strings/0008-ruby-json-gem-cant-handle-this.json +1 -0
- data/spec/acceptance/valid/0005-strings/0009-unescaped-invalid-javascript-still-valid-as-json.json +1 -0
- data/spec/acceptance/valid/0005-strings/0010-escaped-separated-surrogate.json +1 -0
- data/spec/acceptance/valid/0005-strings/0011-escaped-surrogate-then-normal.json +1 -0
- data/spec/acceptance/valid/0006-m17n/0001-genesis.json +6 -0
- data/spec/acceptance/valid/0006-m17n/0002-heart-sutra.json +5 -0
- data/spec/acceptance/valid/0006-m17n/0003-escaped-valid-surrogate-pair.json +1 -0
- data/spec/acceptance/valid/0006-m17n/0004-unescaped-valid-supplementary-multilingual-plane.json +1 -0
- data/spec/acceptance/valid/0007-arrays/0000-empty.json +1 -0
- data/spec/acceptance/valid/0007-arrays/0001-one-element.json +1 -0
- data/spec/acceptance/valid/0007-arrays/0002-multiple-elements.json +33 -0
- data/spec/acceptance/valid/0007-arrays/0003-various-types.json +1 -0
- data/spec/acceptance/valid/0007-arrays/0004-nested.json +17 -0
- data/spec/acceptance/valid/0008-hashes/0000-empty.json +1 -0
- data/spec/acceptance/valid/0008-hashes/0001-onekey.json +1 -0
- data/spec/acceptance/valid/0008-hashes/0002-many-keys.json +5 -0
- data/spec/acceptance/valid/0008-hashes/0003-empty-key.json +3 -0
- data/spec/acceptance/valid/0008-hashes/0004-true-value.json +3 -0
- data/spec/acceptance/valid/0008-hashes/0005-false-value.json +3 -0
- data/spec/acceptance/valid/0008-hashes/0006-null-value.json +3 -0
- data/spec/acceptance/valid/0008-hashes/0007-string-value.json +3 -0
- data/spec/acceptance/valid/0008-hashes/0008-numeric-value.json +3 -0
- data/spec/acceptance/valid/0008-hashes/0009-array-value.json +8 -0
- data/spec/acceptance/valid/0008-hashes/0010-hash-value.json +20 -0
- data/spec/acceptance/valid/0008-hashes/0011-duplicate-key.json +4 -0
- data/spec/acceptance/valid/0008-hashes/0012-duplicate-key-in-different-representations.json +4 -0
- data/spec/acceptance/valid/0009-complicated/0001-jsonschema.json +46 -0
- data/spec/acceptance/valid/0009-complicated/0002-example-in-RFC7159-section-13.json +14 -0
- data/spec/acceptance/valid/0009-complicated/0003-example-in-RFC7159-section-13.json +22 -0
- data/spec/spec_helper.rb +60 -0
- metadata +530 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 71bd39fb9eeac81842d3d5828f9f9fe6100bd368cda84f400f219284708e34fc
|
4
|
+
data.tar.gz: 130c359aa65305ddea0b86c82046614928196ce213346e81baedc8c5d7fd31ed
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 77ca858f3d6c17218d61c9a897b23d148e98b38d28a248d9a44b259e0c1ab7dab56517b932e4bf4bffb3c2107ff029303916c7bed079bf33acdeea124eadaff6
|
7
|
+
data.tar.gz: 40ca93e64a2f088c215820a90e29f1b59e4a75b06fd3b800e841920b30f86a99d2e4fe7c820d56ed32411bc12fea47b1e4f69e0a1cd2a9ec50270f4683490b57
|
data/.gitignore
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# Copyright (c) 2014 Urabe, Shyouhei. All rights reserved.
|
2
|
+
#
|
3
|
+
# Redistribution and use in source and binary forms, with or without
|
4
|
+
# modification, are permitted provided that the following conditions are met:
|
5
|
+
#
|
6
|
+
# - Redistributions of source code must retain the above copyright
|
7
|
+
# notice, this list of conditions and the following disclaimer.
|
8
|
+
#
|
9
|
+
# - Redistributions in binary form must reproduce the above copyright
|
10
|
+
# notice, this list of conditions and the following disclaimer in
|
11
|
+
# the documentation and/or other materials provided with the
|
12
|
+
# distribution.
|
13
|
+
#
|
14
|
+
# - Neither the name of Internet Society, IETF or IETF Trust, nor the
|
15
|
+
# names of specific contributors, may be used to endorse or promote
|
16
|
+
# products derived from this software without specific prior written
|
17
|
+
# permission.
|
18
|
+
#
|
19
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
|
20
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
21
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
22
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
23
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
24
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
25
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
26
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
27
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
28
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
29
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
30
|
+
|
31
|
+
*.gem
|
32
|
+
*.rbc
|
33
|
+
.bundle
|
34
|
+
.config
|
35
|
+
.rbenv-version
|
36
|
+
.ruby-version
|
37
|
+
.yardoc
|
38
|
+
Gemfile.lock
|
39
|
+
InstalledFiles
|
40
|
+
_yardoc
|
41
|
+
coverage
|
42
|
+
doc/
|
43
|
+
lib/bundler/man
|
44
|
+
lib/RFC8259/parser.rb
|
45
|
+
lib/RFC8259/parser.tab.rb
|
46
|
+
lib/RFC8259/parser.output
|
47
|
+
pkg
|
48
|
+
rdoc
|
49
|
+
spec/reports
|
50
|
+
test/tmp
|
51
|
+
test/version_tmp
|
52
|
+
tmp
|
53
|
+
vendor
|
54
|
+
|
55
|
+
#
|
56
|
+
# Local Variables:
|
57
|
+
# mode: conf
|
58
|
+
# coding: utf-8-unix
|
59
|
+
# fill-column: 79
|
60
|
+
# default-justification: full
|
61
|
+
# End:
|
data/.rspec
ADDED
data/.yardopts
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
#! /your/favourite/path/to/bundle
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
|
4
|
+
# Copyright (c) 2014 Urabe, Shyouhei. All rights reserved.
|
5
|
+
#
|
6
|
+
# Redistribution and use in source and binary forms, with or without
|
7
|
+
# modification, are permitted provided that the following conditions are met:
|
8
|
+
#
|
9
|
+
# - Redistributions of source code must retain the above copyright
|
10
|
+
# notice, this list of conditions and the following disclaimer.
|
11
|
+
#
|
12
|
+
# - Redistributions in binary form must reproduce the above copyright
|
13
|
+
# notice, this list of conditions and the following disclaimer in
|
14
|
+
# the documentation and/or other materials provided with the
|
15
|
+
# distribution.
|
16
|
+
#
|
17
|
+
# - Neither the name of Internet Society, IETF or IETF Trust, nor the
|
18
|
+
# names of specific contributors, may be used to endorse or promote
|
19
|
+
# products derived from this software without specific prior written
|
20
|
+
# permission.
|
21
|
+
#
|
22
|
+
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS”
|
23
|
+
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
24
|
+
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
25
|
+
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
26
|
+
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
27
|
+
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
28
|
+
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
29
|
+
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
30
|
+
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
31
|
+
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
32
|
+
# POSSIBILITY OF SUCH DAMAGE.
|
33
|
+
|
34
|
+
begin
|
35
|
+
source 'https://rubygems.org'
|
36
|
+
gemspec require: false
|
37
|
+
|
38
|
+
rescue Bundler::GemspecError
|
39
|
+
# HACK: in order to use bundler we need a valid gemspec, and a valid gemspec
|
40
|
+
# needs a valid parser.rb. A valid parser.rb needs racc, and racc needs
|
41
|
+
# bundler. So there is a circular dependency. We have to workaround.
|
42
|
+
|
43
|
+
require 'fileutils'
|
44
|
+
FileUtils.touch 'lib/RFC8259/parser.rb', mtime: 0
|
45
|
+
gemspec
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
#
|
50
|
+
# Local Variables:
|
51
|
+
# mode: ruby
|
52
|
+
# coding: utf-8-unix
|
53
|
+
# indent-tabs-mode: t
|
54
|
+
# tab-width: 3
|
55
|
+
# ruby-indent-level: 3
|
56
|
+
# fill-column: 79
|
57
|
+
# default-justification: full
|
58
|
+
# End:
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
The file “README.txt” and “RFC8259” (identical contents) is an
|
2
|
+
Internet Engineering Task Force (IETF) document and is copied here
|
3
|
+
under IETF Trust's Legal Provision (TLP) version 5.0 section 3.c.i
|
4
|
+
|
5
|
+
http://trustee.ietf.org/trust-legal-provisions.html
|
6
|
+
|
7
|
+
All other files are my work, not copied from elsewhere. But to avoid
|
8
|
+
conflicts against IETF TLP section 4.e, I hereby put them under
|
9
|
+
"Simplified BSD License" that the provision says.
|
10
|
+
|
11
|
+
Copyright (c) 2014 Urabe, Shyouhei. All rights reserved.
|
12
|
+
|
13
|
+
Redistribution and use in source and binary forms, with or without
|
14
|
+
modification, are permitted provided that the following conditions are
|
15
|
+
met:
|
16
|
+
|
17
|
+
- Redistributions of source code must retain the above copyright
|
18
|
+
notice, this list of conditions and the following disclaimer.
|
19
|
+
|
20
|
+
- Redistributions in binary form must reproduce the above copyright
|
21
|
+
notice, this list of conditions and the following disclaimer in
|
22
|
+
the documentation and/or other materials provided with the
|
23
|
+
distribution.
|
24
|
+
|
25
|
+
- Neither the name of Internet Society, IETF or IETF Trust, nor the
|
26
|
+
names of specific contributors, may be used to endorse or promote
|
27
|
+
products derived from this software without specific prior written
|
28
|
+
permission.
|
29
|
+
|
30
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
31
|
+
“AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
32
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
33
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
34
|
+
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
35
|
+
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
36
|
+
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
37
|
+
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
38
|
+
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
39
|
+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
40
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
./RFC8259
|
data/RFC8259
ADDED
@@ -0,0 +1,899 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
|
5
|
+
|
6
|
+
|
7
|
+
Internet Engineering Task Force (IETF) T. Bray, Ed.
|
8
|
+
Request for Comments: 8259 Textuality
|
9
|
+
Obsoletes: 7159 December 2017
|
10
|
+
Category: Standards Track
|
11
|
+
ISSN: 2070-1721
|
12
|
+
|
13
|
+
|
14
|
+
The JavaScript Object Notation (JSON) Data Interchange Format
|
15
|
+
|
16
|
+
Abstract
|
17
|
+
|
18
|
+
JavaScript Object Notation (JSON) is a lightweight, text-based,
|
19
|
+
language-independent data interchange format. It was derived from
|
20
|
+
the ECMAScript Programming Language Standard. JSON defines a small
|
21
|
+
set of formatting rules for the portable representation of structured
|
22
|
+
data.
|
23
|
+
|
24
|
+
This document removes inconsistencies with other specifications of
|
25
|
+
JSON, repairs specification errors, and offers experience-based
|
26
|
+
interoperability guidance.
|
27
|
+
|
28
|
+
Status of This Memo
|
29
|
+
|
30
|
+
This is an Internet Standards Track document.
|
31
|
+
|
32
|
+
This document is a product of the Internet Engineering Task Force
|
33
|
+
(IETF). It represents the consensus of the IETF community. It has
|
34
|
+
received public review and has been approved for publication by the
|
35
|
+
Internet Engineering Steering Group (IESG). Further information on
|
36
|
+
Internet Standards is available in Section 2 of RFC 7841.
|
37
|
+
|
38
|
+
Information about the current status of this document, any errata,
|
39
|
+
and how to provide feedback on it may be obtained at
|
40
|
+
https://www.rfc-editor.org/info/rfc8259.
|
41
|
+
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
|
56
|
+
|
57
|
+
|
58
|
+
Bray Standards Track [Page 1]
|
59
|
+
|
60
|
+
RFC 8259 JSON December 2017
|
61
|
+
|
62
|
+
|
63
|
+
Copyright Notice
|
64
|
+
|
65
|
+
Copyright (c) 2017 IETF Trust and the persons identified as the
|
66
|
+
document authors. All rights reserved.
|
67
|
+
|
68
|
+
This document is subject to BCP 78 and the IETF Trust's Legal
|
69
|
+
Provisions Relating to IETF Documents
|
70
|
+
(https://trustee.ietf.org/license-info) in effect on the date of
|
71
|
+
publication of this document. Please review these documents
|
72
|
+
carefully, as they describe your rights and restrictions with respect
|
73
|
+
to this document. Code Components extracted from this document must
|
74
|
+
include Simplified BSD License text as described in Section 4.e of
|
75
|
+
the Trust Legal Provisions and are provided without warranty as
|
76
|
+
described in the Simplified BSD License.
|
77
|
+
|
78
|
+
This document may contain material from IETF Documents or IETF
|
79
|
+
Contributions published or made publicly available before November
|
80
|
+
10, 2008. The person(s) controlling the copyright in some of this
|
81
|
+
material may not have granted the IETF Trust the right to allow
|
82
|
+
modifications of such material outside the IETF Standards Process.
|
83
|
+
Without obtaining an adequate license from the person(s) controlling
|
84
|
+
the copyright in such materials, this document may not be modified
|
85
|
+
outside the IETF Standards Process, and derivative works of it may
|
86
|
+
not be created outside the IETF Standards Process, except to format
|
87
|
+
it for publication as an RFC or to translate it into languages other
|
88
|
+
than English.
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
|
106
|
+
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
|
112
|
+
|
113
|
+
|
114
|
+
Bray Standards Track [Page 2]
|
115
|
+
|
116
|
+
RFC 8259 JSON December 2017
|
117
|
+
|
118
|
+
|
119
|
+
Table of Contents
|
120
|
+
|
121
|
+
1. Introduction . . . . . . . . . . . . . . . . . . . . . . . . 3
|
122
|
+
1.1. Conventions Used in This Document . . . . . . . . . . . . 4
|
123
|
+
1.2. Specifications of JSON . . . . . . . . . . . . . . . . . 4
|
124
|
+
1.3. Introduction to This Revision . . . . . . . . . . . . . . 5
|
125
|
+
2. JSON Grammar . . . . . . . . . . . . . . . . . . . . . . . . 5
|
126
|
+
3. Values . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
|
127
|
+
4. Objects . . . . . . . . . . . . . . . . . . . . . . . . . . . 6
|
128
|
+
5. Arrays . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
|
129
|
+
6. Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
|
130
|
+
7. Strings . . . . . . . . . . . . . . . . . . . . . . . . . . . 8
|
131
|
+
8. String and Character Issues . . . . . . . . . . . . . . . . . 9
|
132
|
+
8.1. Character Encoding . . . . . . . . . . . . . . . . . . . 9
|
133
|
+
8.2. Unicode Characters . . . . . . . . . . . . . . . . . . . 10
|
134
|
+
8.3. String Comparison . . . . . . . . . . . . . . . . . . . . 10
|
135
|
+
9. Parsers . . . . . . . . . . . . . . . . . . . . . . . . . . . 10
|
136
|
+
10. Generators . . . . . . . . . . . . . . . . . . . . . . . . . 10
|
137
|
+
11. IANA Considerations . . . . . . . . . . . . . . . . . . . . . 11
|
138
|
+
12. Security Considerations . . . . . . . . . . . . . . . . . . . 12
|
139
|
+
13. Examples . . . . . . . . . . . . . . . . . . . . . . . . . . 12
|
140
|
+
14. References . . . . . . . . . . . . . . . . . . . . . . . . . 14
|
141
|
+
14.1. Normative References . . . . . . . . . . . . . . . . . . 14
|
142
|
+
14.2. Informative References . . . . . . . . . . . . . . . . . 14
|
143
|
+
Appendix A. Changes from RFC 7159 . . . . . . . . . . . . . . . 16
|
144
|
+
Contributors . . . . . . . . . . . . . . . . . . . . . . . . . . 16
|
145
|
+
Author's Address . . . . . . . . . . . . . . . . . . . . . . . . 16
|
146
|
+
|
147
|
+
1. Introduction
|
148
|
+
|
149
|
+
JavaScript Object Notation (JSON) is a text format for the
|
150
|
+
serialization of structured data. It is derived from the object
|
151
|
+
literals of JavaScript, as defined in the ECMAScript Programming
|
152
|
+
Language Standard, Third Edition [ECMA-262].
|
153
|
+
|
154
|
+
JSON can represent four primitive types (strings, numbers, booleans,
|
155
|
+
and null) and two structured types (objects and arrays).
|
156
|
+
|
157
|
+
A string is a sequence of zero or more Unicode characters [UNICODE].
|
158
|
+
Note that this citation references the latest version of Unicode
|
159
|
+
rather than a specific release. It is not expected that future
|
160
|
+
changes in the Unicode specification will impact the syntax of JSON.
|
161
|
+
|
162
|
+
An object is an unordered collection of zero or more name/value
|
163
|
+
pairs, where a name is a string and a value is a string, number,
|
164
|
+
boolean, null, object, or array.
|
165
|
+
|
166
|
+
An array is an ordered sequence of zero or more values.
|
167
|
+
|
168
|
+
|
169
|
+
|
170
|
+
Bray Standards Track [Page 3]
|
171
|
+
|
172
|
+
RFC 8259 JSON December 2017
|
173
|
+
|
174
|
+
|
175
|
+
The terms "object" and "array" come from the conventions of
|
176
|
+
JavaScript.
|
177
|
+
|
178
|
+
JSON's design goals were for it to be minimal, portable, textual, and
|
179
|
+
a subset of JavaScript.
|
180
|
+
|
181
|
+
1.1. Conventions Used in This Document
|
182
|
+
|
183
|
+
The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
|
184
|
+
"SHOULD", "SHOULD NOT", "RECOMMENDED", "NOT RECOMMENDED", "MAY", and
|
185
|
+
"OPTIONAL" in this document are to be interpreted as described in BCP
|
186
|
+
14 [RFC2119] [RFC8174] when, and only when, they appear in all
|
187
|
+
capitals, as shown here.
|
188
|
+
|
189
|
+
The grammatical rules in this document are to be interpreted as
|
190
|
+
described in [RFC5234].
|
191
|
+
|
192
|
+
1.2. Specifications of JSON
|
193
|
+
|
194
|
+
This document replaces [RFC7159]. [RFC7159] obsoleted [RFC4627],
|
195
|
+
which originally described JSON and registered the media type
|
196
|
+
"application/json".
|
197
|
+
|
198
|
+
JSON is also described in [ECMA-404].
|
199
|
+
|
200
|
+
The reference to ECMA-404 in the previous sentence is normative, not
|
201
|
+
with the usual meaning that implementors need to consult it in order
|
202
|
+
to understand this document, but to emphasize that there are no
|
203
|
+
inconsistencies in the definition of the term "JSON text" in any of
|
204
|
+
its specifications. Note, however, that ECMA-404 allows several
|
205
|
+
practices that this specification recommends avoiding in the
|
206
|
+
interests of maximal interoperability.
|
207
|
+
|
208
|
+
The intent is that the grammar is the same between the two documents,
|
209
|
+
although different descriptions are used. If there is a difference
|
210
|
+
found between them, ECMA and the IETF will work together to update
|
211
|
+
both documents.
|
212
|
+
|
213
|
+
If an error is found with either document, the other should be
|
214
|
+
examined to see if it has a similar error; if it does, it should be
|
215
|
+
fixed, if possible.
|
216
|
+
|
217
|
+
If either document is changed in the future, ECMA and the IETF will
|
218
|
+
work together to ensure that the two documents stay aligned through
|
219
|
+
the change.
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
|
225
|
+
|
226
|
+
Bray Standards Track [Page 4]
|
227
|
+
|
228
|
+
RFC 8259 JSON December 2017
|
229
|
+
|
230
|
+
|
231
|
+
1.3. Introduction to This Revision
|
232
|
+
|
233
|
+
In the years since the publication of RFC 4627, JSON has found very
|
234
|
+
wide use. This experience has revealed certain patterns that, while
|
235
|
+
allowed by its specifications, have caused interoperability problems.
|
236
|
+
|
237
|
+
Also, a small number of errata have been reported regarding RFC 4627
|
238
|
+
(see RFC Errata IDs 607 [Err607] and 3607 [Err3607]) and regarding
|
239
|
+
RFC 7159 (see RFC Errata IDs 3915 [Err3915], 4264 [Err4264], 4336
|
240
|
+
[Err4336], and 4388 [Err4388]).
|
241
|
+
|
242
|
+
This document's goal is to apply the errata, remove inconsistencies
|
243
|
+
with other specifications of JSON, and highlight practices that can
|
244
|
+
lead to interoperability problems.
|
245
|
+
|
246
|
+
2. JSON Grammar
|
247
|
+
|
248
|
+
A JSON text is a sequence of tokens. The set of tokens includes six
|
249
|
+
structural characters, strings, numbers, and three literal names.
|
250
|
+
|
251
|
+
A JSON text is a serialized value. Note that certain previous
|
252
|
+
specifications of JSON constrained a JSON text to be an object or an
|
253
|
+
array. Implementations that generate only objects or arrays where a
|
254
|
+
JSON text is called for will be interoperable in the sense that all
|
255
|
+
implementations will accept these as conforming JSON texts.
|
256
|
+
|
257
|
+
JSON-text = ws value ws
|
258
|
+
|
259
|
+
These are the six structural characters:
|
260
|
+
|
261
|
+
begin-array = ws %x5B ws ; [ left square bracket
|
262
|
+
|
263
|
+
begin-object = ws %x7B ws ; { left curly bracket
|
264
|
+
|
265
|
+
end-array = ws %x5D ws ; ] right square bracket
|
266
|
+
|
267
|
+
end-object = ws %x7D ws ; } right curly bracket
|
268
|
+
|
269
|
+
name-separator = ws %x3A ws ; : colon
|
270
|
+
|
271
|
+
value-separator = ws %x2C ws ; , comma
|
272
|
+
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
Bray Standards Track [Page 5]
|
283
|
+
|
284
|
+
RFC 8259 JSON December 2017
|
285
|
+
|
286
|
+
|
287
|
+
Insignificant whitespace is allowed before or after any of the six
|
288
|
+
structural characters.
|
289
|
+
|
290
|
+
ws = *(
|
291
|
+
%x20 / ; Space
|
292
|
+
%x09 / ; Horizontal tab
|
293
|
+
%x0A / ; Line feed or New line
|
294
|
+
%x0D ) ; Carriage return
|
295
|
+
|
296
|
+
3. Values
|
297
|
+
|
298
|
+
A JSON value MUST be an object, array, number, or string, or one of
|
299
|
+
the following three literal names:
|
300
|
+
|
301
|
+
false
|
302
|
+
null
|
303
|
+
true
|
304
|
+
|
305
|
+
The literal names MUST be lowercase. No other literal names are
|
306
|
+
allowed.
|
307
|
+
|
308
|
+
value = false / null / true / object / array / number / string
|
309
|
+
|
310
|
+
false = %x66.61.6c.73.65 ; false
|
311
|
+
|
312
|
+
null = %x6e.75.6c.6c ; null
|
313
|
+
|
314
|
+
true = %x74.72.75.65 ; true
|
315
|
+
|
316
|
+
4. Objects
|
317
|
+
|
318
|
+
An object structure is represented as a pair of curly brackets
|
319
|
+
surrounding zero or more name/value pairs (or members). A name is a
|
320
|
+
string. A single colon comes after each name, separating the name
|
321
|
+
from the value. A single comma separates a value from a following
|
322
|
+
name. The names within an object SHOULD be unique.
|
323
|
+
|
324
|
+
object = begin-object [ member *( value-separator member ) ]
|
325
|
+
end-object
|
326
|
+
|
327
|
+
member = string name-separator value
|
328
|
+
|
329
|
+
An object whose names are all unique is interoperable in the sense
|
330
|
+
that all software implementations receiving that object will agree on
|
331
|
+
the name-value mappings. When the names within an object are not
|
332
|
+
unique, the behavior of software that receives such an object is
|
333
|
+
unpredictable. Many implementations report the last name/value pair
|
334
|
+
only. Other implementations report an error or fail to parse the
|
335
|
+
|
336
|
+
|
337
|
+
|
338
|
+
Bray Standards Track [Page 6]
|
339
|
+
|
340
|
+
RFC 8259 JSON December 2017
|
341
|
+
|
342
|
+
|
343
|
+
object, and some implementations report all of the name/value pairs,
|
344
|
+
including duplicates.
|
345
|
+
|
346
|
+
JSON parsing libraries have been observed to differ as to whether or
|
347
|
+
not they make the ordering of object members visible to calling
|
348
|
+
software. Implementations whose behavior does not depend on member
|
349
|
+
ordering will be interoperable in the sense that they will not be
|
350
|
+
affected by these differences.
|
351
|
+
|
352
|
+
5. Arrays
|
353
|
+
|
354
|
+
An array structure is represented as square brackets surrounding zero
|
355
|
+
or more values (or elements). Elements are separated by commas.
|
356
|
+
|
357
|
+
array = begin-array [ value *( value-separator value ) ] end-array
|
358
|
+
|
359
|
+
There is no requirement that the values in an array be of the same
|
360
|
+
type.
|
361
|
+
|
362
|
+
6. Numbers
|
363
|
+
|
364
|
+
The representation of numbers is similar to that used in most
|
365
|
+
programming languages. A number is represented in base 10 using
|
366
|
+
decimal digits. It contains an integer component that may be
|
367
|
+
prefixed with an optional minus sign, which may be followed by a
|
368
|
+
fraction part and/or an exponent part. Leading zeros are not
|
369
|
+
allowed.
|
370
|
+
|
371
|
+
A fraction part is a decimal point followed by one or more digits.
|
372
|
+
|
373
|
+
An exponent part begins with the letter E in uppercase or lowercase,
|
374
|
+
which may be followed by a plus or minus sign. The E and optional
|
375
|
+
sign are followed by one or more digits.
|
376
|
+
|
377
|
+
Numeric values that cannot be represented in the grammar below (such
|
378
|
+
as Infinity and NaN) are not permitted.
|
379
|
+
|
380
|
+
number = [ minus ] int [ frac ] [ exp ]
|
381
|
+
|
382
|
+
decimal-point = %x2E ; .
|
383
|
+
|
384
|
+
digit1-9 = %x31-39 ; 1-9
|
385
|
+
|
386
|
+
e = %x65 / %x45 ; e E
|
387
|
+
|
388
|
+
exp = e [ minus / plus ] 1*DIGIT
|
389
|
+
|
390
|
+
frac = decimal-point 1*DIGIT
|
391
|
+
|
392
|
+
|
393
|
+
|
394
|
+
Bray Standards Track [Page 7]
|
395
|
+
|
396
|
+
RFC 8259 JSON December 2017
|
397
|
+
|
398
|
+
|
399
|
+
int = zero / ( digit1-9 *DIGIT )
|
400
|
+
|
401
|
+
minus = %x2D ; -
|
402
|
+
|
403
|
+
plus = %x2B ; +
|
404
|
+
|
405
|
+
zero = %x30 ; 0
|
406
|
+
|
407
|
+
This specification allows implementations to set limits on the range
|
408
|
+
and precision of numbers accepted. Since software that implements
|
409
|
+
IEEE 754 binary64 (double precision) numbers [IEEE754] is generally
|
410
|
+
available and widely used, good interoperability can be achieved by
|
411
|
+
implementations that expect no more precision or range than these
|
412
|
+
provide, in the sense that implementations will approximate JSON
|
413
|
+
numbers within the expected precision. A JSON number such as 1E400
|
414
|
+
or 3.141592653589793238462643383279 may indicate potential
|
415
|
+
interoperability problems, since it suggests that the software that
|
416
|
+
created it expects receiving software to have greater capabilities
|
417
|
+
for numeric magnitude and precision than is widely available.
|
418
|
+
|
419
|
+
Note that when such software is used, numbers that are integers and
|
420
|
+
are in the range [-(2**53)+1, (2**53)-1] are interoperable in the
|
421
|
+
sense that implementations will agree exactly on their numeric
|
422
|
+
values.
|
423
|
+
|
424
|
+
7. Strings
|
425
|
+
|
426
|
+
The representation of strings is similar to conventions used in the C
|
427
|
+
family of programming languages. A string begins and ends with
|
428
|
+
quotation marks. All Unicode characters may be placed within the
|
429
|
+
quotation marks, except for the characters that MUST be escaped:
|
430
|
+
quotation mark, reverse solidus, and the control characters (U+0000
|
431
|
+
through U+001F).
|
432
|
+
|
433
|
+
Any character may be escaped. If the character is in the Basic
|
434
|
+
Multilingual Plane (U+0000 through U+FFFF), then it may be
|
435
|
+
represented as a six-character sequence: a reverse solidus, followed
|
436
|
+
by the lowercase letter u, followed by four hexadecimal digits that
|
437
|
+
encode the character's code point. The hexadecimal letters A through
|
438
|
+
F can be uppercase or lowercase. So, for example, a string
|
439
|
+
containing only a single reverse solidus character may be represented
|
440
|
+
as "\u005C".
|
441
|
+
|
442
|
+
Alternatively, there are two-character sequence escape
|
443
|
+
representations of some popular characters. So, for example, a
|
444
|
+
string containing only a single reverse solidus character may be
|
445
|
+
represented more compactly as "\\".
|
446
|
+
|
447
|
+
|
448
|
+
|
449
|
+
|
450
|
+
Bray Standards Track [Page 8]
|
451
|
+
|
452
|
+
RFC 8259 JSON December 2017
|
453
|
+
|
454
|
+
|
455
|
+
To escape an extended character that is not in the Basic Multilingual
|
456
|
+
Plane, the character is represented as a 12-character sequence,
|
457
|
+
encoding the UTF-16 surrogate pair. So, for example, a string
|
458
|
+
containing only the G clef character (U+1D11E) may be represented as
|
459
|
+
"\uD834\uDD1E".
|
460
|
+
|
461
|
+
string = quotation-mark *char quotation-mark
|
462
|
+
|
463
|
+
char = unescaped /
|
464
|
+
escape (
|
465
|
+
%x22 / ; " quotation mark U+0022
|
466
|
+
%x5C / ; \ reverse solidus U+005C
|
467
|
+
%x2F / ; / solidus U+002F
|
468
|
+
%x62 / ; b backspace U+0008
|
469
|
+
%x66 / ; f form feed U+000C
|
470
|
+
%x6E / ; n line feed U+000A
|
471
|
+
%x72 / ; r carriage return U+000D
|
472
|
+
%x74 / ; t tab U+0009
|
473
|
+
%x75 4HEXDIG ) ; uXXXX U+XXXX
|
474
|
+
|
475
|
+
escape = %x5C ; \
|
476
|
+
|
477
|
+
quotation-mark = %x22 ; "
|
478
|
+
|
479
|
+
unescaped = %x20-21 / %x23-5B / %x5D-10FFFF
|
480
|
+
|
481
|
+
8. String and Character Issues
|
482
|
+
|
483
|
+
8.1. Character Encoding
|
484
|
+
|
485
|
+
JSON text exchanged between systems that are not part of a closed
|
486
|
+
ecosystem MUST be encoded using UTF-8 [RFC3629].
|
487
|
+
|
488
|
+
Previous specifications of JSON have not required the use of UTF-8
|
489
|
+
when transmitting JSON text. However, the vast majority of JSON-
|
490
|
+
based software implementations have chosen to use the UTF-8 encoding,
|
491
|
+
to the extent that it is the only encoding that achieves
|
492
|
+
interoperability.
|
493
|
+
|
494
|
+
Implementations MUST NOT add a byte order mark (U+FEFF) to the
|
495
|
+
beginning of a networked-transmitted JSON text. In the interests of
|
496
|
+
interoperability, implementations that parse JSON texts MAY ignore
|
497
|
+
the presence of a byte order mark rather than treating it as an
|
498
|
+
error.
|
499
|
+
|
500
|
+
|
501
|
+
|
502
|
+
|
503
|
+
|
504
|
+
|
505
|
+
|
506
|
+
Bray Standards Track [Page 9]
|
507
|
+
|
508
|
+
RFC 8259 JSON December 2017
|
509
|
+
|
510
|
+
|
511
|
+
8.2. Unicode Characters
|
512
|
+
|
513
|
+
When all the strings represented in a JSON text are composed entirely
|
514
|
+
of Unicode characters [UNICODE] (however escaped), then that JSON
|
515
|
+
text is interoperable in the sense that all software implementations
|
516
|
+
that parse it will agree on the contents of names and of string
|
517
|
+
values in objects and arrays.
|
518
|
+
|
519
|
+
However, the ABNF in this specification allows member names and
|
520
|
+
string values to contain bit sequences that cannot encode Unicode
|
521
|
+
characters; for example, "\uDEAD" (a single unpaired UTF-16
|
522
|
+
surrogate). Instances of this have been observed, for example, when
|
523
|
+
a library truncates a UTF-16 string without checking whether the
|
524
|
+
truncation split a surrogate pair. The behavior of software that
|
525
|
+
receives JSON texts containing such values is unpredictable; for
|
526
|
+
example, implementations might return different values for the length
|
527
|
+
of a string value or even suffer fatal runtime exceptions.
|
528
|
+
|
529
|
+
8.3. String Comparison
|
530
|
+
|
531
|
+
Software implementations are typically required to test names of
|
532
|
+
object members for equality. Implementations that transform the
|
533
|
+
textual representation into sequences of Unicode code units and then
|
534
|
+
perform the comparison numerically, code unit by code unit, are
|
535
|
+
interoperable in the sense that implementations will agree in all
|
536
|
+
cases on equality or inequality of two strings. For example,
|
537
|
+
implementations that compare strings with escaped characters
|
538
|
+
unconverted may incorrectly find that "a\\b" and "a\u005Cb" are not
|
539
|
+
equal.
|
540
|
+
|
541
|
+
9. Parsers
|
542
|
+
|
543
|
+
A JSON parser transforms a JSON text into another representation. A
|
544
|
+
JSON parser MUST accept all texts that conform to the JSON grammar.
|
545
|
+
A JSON parser MAY accept non-JSON forms or extensions.
|
546
|
+
|
547
|
+
An implementation may set limits on the size of texts that it
|
548
|
+
accepts. An implementation may set limits on the maximum depth of
|
549
|
+
nesting. An implementation may set limits on the range and precision
|
550
|
+
of numbers. An implementation may set limits on the length and
|
551
|
+
character contents of strings.
|
552
|
+
|
553
|
+
10. Generators
|
554
|
+
|
555
|
+
A JSON generator produces JSON text. The resulting text MUST
|
556
|
+
strictly conform to the JSON grammar.
|
557
|
+
|
558
|
+
|
559
|
+
|
560
|
+
|
561
|
+
|
562
|
+
Bray Standards Track [Page 10]
|
563
|
+
|
564
|
+
RFC 8259 JSON December 2017
|
565
|
+
|
566
|
+
|
567
|
+
11. IANA Considerations
|
568
|
+
|
569
|
+
The media type for JSON text is application/json.
|
570
|
+
|
571
|
+
Type name: application
|
572
|
+
|
573
|
+
Subtype name: json
|
574
|
+
|
575
|
+
Required parameters: n/a
|
576
|
+
|
577
|
+
Optional parameters: n/a
|
578
|
+
|
579
|
+
Encoding considerations: binary
|
580
|
+
|
581
|
+
Security considerations: See RFC 8259, Section 12
|
582
|
+
|
583
|
+
Interoperability considerations: Described in RFC 8259
|
584
|
+
|
585
|
+
Published specification: RFC 8259
|
586
|
+
|
587
|
+
Applications that use this media type:
|
588
|
+
JSON has been used to exchange data between applications written
|
589
|
+
in all of these programming languages: ActionScript, C, C#,
|
590
|
+
Clojure, ColdFusion, Common Lisp, E, Erlang, Go, Java, JavaScript,
|
591
|
+
Lua, Objective CAML, Perl, PHP, Python, Rebol, Ruby, Scala, and
|
592
|
+
Scheme.
|
593
|
+
|
594
|
+
Additional information:
|
595
|
+
Magic number(s): n/a
|
596
|
+
File extension(s): .json
|
597
|
+
Macintosh file type code(s): TEXT
|
598
|
+
|
599
|
+
Person & email address to contact for further information:
|
600
|
+
IESG
|
601
|
+
<iesg@ietf.org>
|
602
|
+
|
603
|
+
Intended usage: COMMON
|
604
|
+
|
605
|
+
Restrictions on usage: none
|
606
|
+
|
607
|
+
Author:
|
608
|
+
Douglas Crockford
|
609
|
+
<douglas@crockford.com>
|
610
|
+
|
611
|
+
Change controller:
|
612
|
+
IESG
|
613
|
+
<iesg@ietf.org>
|
614
|
+
|
615
|
+
|
616
|
+
|
617
|
+
|
618
|
+
Bray Standards Track [Page 11]
|
619
|
+
|
620
|
+
RFC 8259 JSON December 2017
|
621
|
+
|
622
|
+
|
623
|
+
Note: No "charset" parameter is defined for this registration.
|
624
|
+
Adding one really has no effect on compliant recipients.
|
625
|
+
|
626
|
+
12. Security Considerations
|
627
|
+
|
628
|
+
Generally, there are security issues with scripting languages. JSON
|
629
|
+
is a subset of JavaScript but excludes assignment and invocation.
|
630
|
+
|
631
|
+
Since JSON's syntax is borrowed from JavaScript, it is possible to
|
632
|
+
use that language's "eval()" function to parse most JSON texts (but
|
633
|
+
not all; certain characters such as U+2028 LINE SEPARATOR and U+2029
|
634
|
+
PARAGRAPH SEPARATOR are legal in JSON but not JavaScript). This
|
635
|
+
generally constitutes an unacceptable security risk, since the text
|
636
|
+
could contain executable code along with data declarations. The same
|
637
|
+
consideration applies to the use of eval()-like functions in any
|
638
|
+
other programming language in which JSON texts conform to that
|
639
|
+
language's syntax.
|
640
|
+
|
641
|
+
13. Examples
|
642
|
+
|
643
|
+
This is a JSON object:
|
644
|
+
|
645
|
+
{
|
646
|
+
"Image": {
|
647
|
+
"Width": 800,
|
648
|
+
"Height": 600,
|
649
|
+
"Title": "View from 15th Floor",
|
650
|
+
"Thumbnail": {
|
651
|
+
"Url": "http://www.example.com/image/481989943",
|
652
|
+
"Height": 125,
|
653
|
+
"Width": 100
|
654
|
+
},
|
655
|
+
"Animated" : false,
|
656
|
+
"IDs": [116, 943, 234, 38793]
|
657
|
+
}
|
658
|
+
}
|
659
|
+
|
660
|
+
Its Image member is an object whose Thumbnail member is an object and
|
661
|
+
whose IDs member is an array of numbers.
|
662
|
+
|
663
|
+
|
664
|
+
|
665
|
+
|
666
|
+
|
667
|
+
|
668
|
+
|
669
|
+
|
670
|
+
|
671
|
+
|
672
|
+
|
673
|
+
|
674
|
+
Bray Standards Track [Page 12]
|
675
|
+
|
676
|
+
RFC 8259 JSON December 2017
|
677
|
+
|
678
|
+
|
679
|
+
This is a JSON array containing two objects:
|
680
|
+
|
681
|
+
[
|
682
|
+
{
|
683
|
+
"precision": "zip",
|
684
|
+
"Latitude": 37.7668,
|
685
|
+
"Longitude": -122.3959,
|
686
|
+
"Address": "",
|
687
|
+
"City": "SAN FRANCISCO",
|
688
|
+
"State": "CA",
|
689
|
+
"Zip": "94107",
|
690
|
+
"Country": "US"
|
691
|
+
},
|
692
|
+
{
|
693
|
+
"precision": "zip",
|
694
|
+
"Latitude": 37.371991,
|
695
|
+
"Longitude": -122.026020,
|
696
|
+
"Address": "",
|
697
|
+
"City": "SUNNYVALE",
|
698
|
+
"State": "CA",
|
699
|
+
"Zip": "94085",
|
700
|
+
"Country": "US"
|
701
|
+
}
|
702
|
+
]
|
703
|
+
|
704
|
+
Here are three small JSON texts containing only values:
|
705
|
+
|
706
|
+
"Hello world!"
|
707
|
+
|
708
|
+
42
|
709
|
+
|
710
|
+
true
|
711
|
+
|
712
|
+
|
713
|
+
|
714
|
+
|
715
|
+
|
716
|
+
|
717
|
+
|
718
|
+
|
719
|
+
|
720
|
+
|
721
|
+
|
722
|
+
|
723
|
+
|
724
|
+
|
725
|
+
|
726
|
+
|
727
|
+
|
728
|
+
|
729
|
+
|
730
|
+
Bray Standards Track [Page 13]
|
731
|
+
|
732
|
+
RFC 8259 JSON December 2017
|
733
|
+
|
734
|
+
|
735
|
+
14. References
|
736
|
+
|
737
|
+
14.1. Normative References
|
738
|
+
|
739
|
+
[ECMA-404] Ecma International, "The JSON Data Interchange Format",
|
740
|
+
Standard ECMA-404,
|
741
|
+
<http://www.ecma-international.org/publications/
|
742
|
+
standards/Ecma-404.htm>.
|
743
|
+
|
744
|
+
[IEEE754] IEEE, "IEEE Standard for Floating-Point Arithmetic",
|
745
|
+
IEEE 754.
|
746
|
+
|
747
|
+
[RFC2119] Bradner, S., "Key words for use in RFCs to Indicate
|
748
|
+
Requirement Levels", BCP 14, RFC 2119,
|
749
|
+
DOI 10.17487/RFC2119, March 1997,
|
750
|
+
<https://www.rfc-editor.org/info/rfc2119>.
|
751
|
+
|
752
|
+
[RFC3629] Yergeau, F., "UTF-8, a transformation format of ISO
|
753
|
+
10646", STD 63, RFC 3629, DOI 10.17487/RFC3629, November
|
754
|
+
2003, <https://www.rfc-editor.org/info/rfc3629>.
|
755
|
+
|
756
|
+
[RFC5234] Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax
|
757
|
+
Specifications: ABNF", STD 68, RFC 5234,
|
758
|
+
DOI 10.17487/RFC5234, January 2008,
|
759
|
+
<https://www.rfc-editor.org/info/rfc5234>.
|
760
|
+
|
761
|
+
[RFC8174] Leiba, B., "Ambiguity of Uppercase vs Lowercase in RFC
|
762
|
+
2119 Key Words", BCP 14, RFC 8174, DOI 10.17487/RFC8174,
|
763
|
+
May 2017, <https://www.rfc-editor.org/info/rfc8174>.
|
764
|
+
|
765
|
+
[UNICODE] The Unicode Consortium, "The Unicode Standard",
|
766
|
+
<http://www.unicode.org/versions/latest/>.
|
767
|
+
|
768
|
+
14.2. Informative References
|
769
|
+
|
770
|
+
[ECMA-262] Ecma International, "ECMAScript Language Specification",
|
771
|
+
Standard ECMA-262, Third Edition, December 1999,
|
772
|
+
<http://www.ecma-international.org/publications/files/
|
773
|
+
ECMA-ST-ARCH/
|
774
|
+
ECMA-262,%203rd%20edition,%20December%201999.pdf>.
|
775
|
+
|
776
|
+
[Err3607] RFC Errata, Erratum ID 3607, RFC 4627,
|
777
|
+
<https://www.rfc-editor.org/errata/eid3607>.
|
778
|
+
|
779
|
+
[Err3915] RFC Errata, Erratum ID 3915, RFC 7159,
|
780
|
+
<https://www.rfc-editor.org/errata/eid3915>.
|
781
|
+
|
782
|
+
|
783
|
+
|
784
|
+
|
785
|
+
|
786
|
+
Bray Standards Track [Page 14]
|
787
|
+
|
788
|
+
RFC 8259 JSON December 2017
|
789
|
+
|
790
|
+
|
791
|
+
[Err4264] RFC Errata, Erratum ID 4264, RFC 7159,
|
792
|
+
<https://www.rfc-editor.org/errata/eid4264>.
|
793
|
+
|
794
|
+
[Err4336] RFC Errata, Erratum ID 4336, RFC 7159,
|
795
|
+
<https://www.rfc-editor.org/errata/eid4336>.
|
796
|
+
|
797
|
+
[Err4388] RFC Errata, Erratum ID 4388, RFC 7159,
|
798
|
+
<https://www.rfc-editor.org/errata/eid4388>.
|
799
|
+
|
800
|
+
[Err607] RFC Errata, Erratum ID 607, RFC 4627,
|
801
|
+
<https://www.rfc-editor.org/errata/eid607>.
|
802
|
+
|
803
|
+
[RFC4627] Crockford, D., "The application/json Media Type for
|
804
|
+
JavaScript Object Notation (JSON)", RFC 4627,
|
805
|
+
DOI 10.17487/RFC4627, July 2006,
|
806
|
+
<https://www.rfc-editor.org/info/rfc4627>.
|
807
|
+
|
808
|
+
[RFC7159] Bray, T., Ed., "The JavaScript Object Notation (JSON) Data
|
809
|
+
Interchange Format", RFC 7159, DOI 10.17487/RFC7159, March
|
810
|
+
2014, <https://www.rfc-editor.org/info/rfc7159>.
|
811
|
+
|
812
|
+
|
813
|
+
|
814
|
+
|
815
|
+
|
816
|
+
|
817
|
+
|
818
|
+
|
819
|
+
|
820
|
+
|
821
|
+
|
822
|
+
|
823
|
+
|
824
|
+
|
825
|
+
|
826
|
+
|
827
|
+
|
828
|
+
|
829
|
+
|
830
|
+
|
831
|
+
|
832
|
+
|
833
|
+
|
834
|
+
|
835
|
+
|
836
|
+
|
837
|
+
|
838
|
+
|
839
|
+
|
840
|
+
|
841
|
+
|
842
|
+
Bray Standards Track [Page 15]
|
843
|
+
|
844
|
+
RFC 8259 JSON December 2017
|
845
|
+
|
846
|
+
|
847
|
+
Appendix A. Changes from RFC 7159
|
848
|
+
|
849
|
+
This section lists changes between this document and the text in
|
850
|
+
RFC 7159.
|
851
|
+
|
852
|
+
o Section 1.2 has been updated to reflect the removal of a JSON
|
853
|
+
specification from ECMA-262, to make ECMA-404 a normative
|
854
|
+
reference, and to explain the particular meaning of "normative".
|
855
|
+
|
856
|
+
o Section 1.3 has been updated to reflect errata filed against
|
857
|
+
RFC 7159, not RFC 4627.
|
858
|
+
|
859
|
+
o Section 8.1 was changed to require the use of UTF-8 when
|
860
|
+
transmitted over a network.
|
861
|
+
|
862
|
+
o Section 12 has been updated to increase the precision of the
|
863
|
+
description of the security risk that follows from using the
|
864
|
+
ECMAScript "eval()" function.
|
865
|
+
|
866
|
+
o Section 14.1 has been updated to include ECMA-404 as a normative
|
867
|
+
reference.
|
868
|
+
|
869
|
+
o Section 14.2 has been updated to remove ECMA-404, update the
|
870
|
+
version of ECMA-262, and refresh the errata list.
|
871
|
+
|
872
|
+
Contributors
|
873
|
+
|
874
|
+
RFC 4627 was written by Douglas Crockford. This document was
|
875
|
+
constructed by making a relatively small number of changes to that
|
876
|
+
document; thus, the vast majority of the text here is his.
|
877
|
+
|
878
|
+
Author's Address
|
879
|
+
|
880
|
+
Tim Bray (editor)
|
881
|
+
Textuality
|
882
|
+
|
883
|
+
Email: tbray@textuality.com
|
884
|
+
|
885
|
+
|
886
|
+
|
887
|
+
|
888
|
+
|
889
|
+
|
890
|
+
|
891
|
+
|
892
|
+
|
893
|
+
|
894
|
+
|
895
|
+
|
896
|
+
|
897
|
+
|
898
|
+
Bray Standards Track [Page 16]
|
899
|
+
|