json_pure 1.4.6 → 2.8.1

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.
Files changed (123) hide show
  1. checksums.yaml +7 -0
  2. data/BSDL +22 -0
  3. data/CHANGES.md +544 -0
  4. data/COPYING +14 -16
  5. data/LEGAL +60 -0
  6. data/README.md +219 -0
  7. data/json_pure.gemspec +39 -0
  8. data/lib/json/pure.rb +3 -76
  9. metadata +45 -165
  10. data/CHANGES +0 -179
  11. data/GPL +0 -340
  12. data/README +0 -356
  13. data/Rakefile +0 -292
  14. data/TODO +0 -1
  15. data/VERSION +0 -1
  16. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkComparison.log +0 -52
  17. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast-autocorrelation.dat +0 -1000
  18. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast.dat +0 -1001
  19. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty-autocorrelation.dat +0 -900
  20. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty.dat +0 -901
  21. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe-autocorrelation.dat +0 -1000
  22. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe.dat +0 -1001
  23. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt.log +0 -261
  24. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast-autocorrelation.dat +0 -1000
  25. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast.dat +0 -1001
  26. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty-autocorrelation.dat +0 -1000
  27. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty.dat +0 -1001
  28. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe-autocorrelation.dat +0 -1000
  29. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe.dat +0 -1001
  30. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure.log +0 -262
  31. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator-autocorrelation.dat +0 -1000
  32. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator.dat +0 -1001
  33. data/benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails.log +0 -82
  34. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkComparison.log +0 -34
  35. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser-autocorrelation.dat +0 -900
  36. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser.dat +0 -901
  37. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt.log +0 -81
  38. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser-autocorrelation.dat +0 -1000
  39. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser.dat +0 -1001
  40. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure.log +0 -82
  41. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser-autocorrelation.dat +0 -1000
  42. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser.dat +0 -1001
  43. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails.log +0 -82
  44. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser-autocorrelation.dat +0 -1000
  45. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser.dat +0 -1001
  46. data/benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML.log +0 -82
  47. data/benchmarks/generator2_benchmark.rb +0 -222
  48. data/benchmarks/generator_benchmark.rb +0 -224
  49. data/benchmarks/ohai.json +0 -1216
  50. data/benchmarks/ohai.ruby +0 -1
  51. data/benchmarks/parser2_benchmark.rb +0 -251
  52. data/benchmarks/parser_benchmark.rb +0 -259
  53. data/bin/edit_json.rb +0 -9
  54. data/bin/prettify_json.rb +0 -75
  55. data/data/example.json +0 -1
  56. data/data/index.html +0 -38
  57. data/data/prototype.js +0 -4184
  58. data/ext/json/ext/generator/extconf.rb +0 -20
  59. data/ext/json/ext/generator/generator.c +0 -1417
  60. data/ext/json/ext/generator/generator.h +0 -197
  61. data/ext/json/ext/parser/extconf.rb +0 -15
  62. data/ext/json/ext/parser/parser.c +0 -1935
  63. data/ext/json/ext/parser/parser.h +0 -71
  64. data/ext/json/ext/parser/parser.rl +0 -792
  65. data/install.rb +0 -26
  66. data/lib/json/Array.xpm +0 -21
  67. data/lib/json/FalseClass.xpm +0 -21
  68. data/lib/json/Hash.xpm +0 -21
  69. data/lib/json/Key.xpm +0 -73
  70. data/lib/json/NilClass.xpm +0 -21
  71. data/lib/json/Numeric.xpm +0 -28
  72. data/lib/json/String.xpm +0 -96
  73. data/lib/json/TrueClass.xpm +0 -21
  74. data/lib/json/add/core.rb +0 -148
  75. data/lib/json/add/rails.rb +0 -58
  76. data/lib/json/common.rb +0 -391
  77. data/lib/json/editor.rb +0 -1371
  78. data/lib/json/ext.rb +0 -15
  79. data/lib/json/json.xpm +0 -1499
  80. data/lib/json/pure/generator.rb +0 -439
  81. data/lib/json/pure/parser.rb +0 -309
  82. data/lib/json/version.rb +0 -8
  83. data/lib/json.rb +0 -10
  84. data/tests/fixtures/fail1.json +0 -1
  85. data/tests/fixtures/fail10.json +0 -1
  86. data/tests/fixtures/fail11.json +0 -1
  87. data/tests/fixtures/fail12.json +0 -1
  88. data/tests/fixtures/fail13.json +0 -1
  89. data/tests/fixtures/fail14.json +0 -1
  90. data/tests/fixtures/fail18.json +0 -1
  91. data/tests/fixtures/fail19.json +0 -1
  92. data/tests/fixtures/fail2.json +0 -1
  93. data/tests/fixtures/fail20.json +0 -1
  94. data/tests/fixtures/fail21.json +0 -1
  95. data/tests/fixtures/fail22.json +0 -1
  96. data/tests/fixtures/fail23.json +0 -1
  97. data/tests/fixtures/fail24.json +0 -1
  98. data/tests/fixtures/fail25.json +0 -1
  99. data/tests/fixtures/fail27.json +0 -2
  100. data/tests/fixtures/fail28.json +0 -2
  101. data/tests/fixtures/fail3.json +0 -1
  102. data/tests/fixtures/fail4.json +0 -1
  103. data/tests/fixtures/fail5.json +0 -1
  104. data/tests/fixtures/fail6.json +0 -1
  105. data/tests/fixtures/fail7.json +0 -1
  106. data/tests/fixtures/fail8.json +0 -1
  107. data/tests/fixtures/fail9.json +0 -1
  108. data/tests/fixtures/pass1.json +0 -56
  109. data/tests/fixtures/pass15.json +0 -1
  110. data/tests/fixtures/pass16.json +0 -1
  111. data/tests/fixtures/pass17.json +0 -1
  112. data/tests/fixtures/pass2.json +0 -1
  113. data/tests/fixtures/pass26.json +0 -1
  114. data/tests/fixtures/pass3.json +0 -6
  115. data/tests/test_json.rb +0 -394
  116. data/tests/test_json_addition.rb +0 -162
  117. data/tests/test_json_encoding.rb +0 -68
  118. data/tests/test_json_fixtures.rb +0 -34
  119. data/tests/test_json_generate.rb +0 -181
  120. data/tests/test_json_rails.rb +0 -144
  121. data/tests/test_json_unicode.rb +0 -76
  122. data/tools/fuzz.rb +0 -139
  123. data/tools/server.rb +0 -61
data/LEGAL ADDED
@@ -0,0 +1,60 @@
1
+ # -*- rdoc -*-
2
+
3
+ = LEGAL NOTICE INFORMATION
4
+ --------------------------
5
+
6
+ All the files in this distribution are covered under either the Ruby's
7
+ license (see the file COPYING) or public-domain except some files
8
+ mentioned below.
9
+
10
+ == MIT License
11
+ >>>
12
+ Permission is hereby granted, free of charge, to any person obtaining
13
+ a copy of this software and associated documentation files (the
14
+ "Software"), to deal in the Software without restriction, including
15
+ without limitation the rights to use, copy, modify, merge, publish,
16
+ distribute, sublicense, and/or sell copies of the Software, and to
17
+ permit persons to whom the Software is furnished to do so, subject to
18
+ the following conditions:
19
+
20
+ The above copyright notice and this permission notice shall be
21
+ included in all copies or substantial portions of the Software.
22
+
23
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
26
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
27
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
28
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30
+
31
+ == Old-style BSD license
32
+ >>>
33
+ Redistribution and use in source and binary forms, with or without
34
+ modification, are permitted provided that the following conditions
35
+ are met:
36
+ 1. Redistributions of source code must retain the above copyright
37
+ notice, this list of conditions and the following disclaimer.
38
+ 2. Redistributions in binary form must reproduce the above copyright
39
+ notice, this list of conditions and the following disclaimer in the
40
+ documentation and/or other materials provided with the distribution.
41
+ 3. Neither the name of the University nor the names of its contributors
42
+ may be used to endorse or promote products derived from this software
43
+ without specific prior written permission.
44
+
45
+ THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
46
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
47
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
48
+ ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
49
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
51
+ OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52
+ HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
53
+ LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
54
+ OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
55
+ SUCH DAMAGE.
56
+
57
+ IMPORTANT NOTE::
58
+
59
+ From ftp://ftp.cs.berkeley.edu/pub/4bsd/README.Impt.License.Change
60
+ paragraph 3 above is now null and void.
data/README.md ADDED
@@ -0,0 +1,219 @@
1
+ # JSON implementation for Ruby
2
+
3
+ [![CI](https://github.com/ruby/json/actions/workflows/ci.yml/badge.svg)](https://github.com/ruby/json/actions/workflows/ci.yml)
4
+
5
+ ## Description
6
+
7
+ This is an implementation of the JSON specification according to RFC 7159
8
+ http://www.ietf.org/rfc/rfc7159.txt .
9
+
10
+ The JSON generator generate UTF-8 character sequences by default.
11
+ If an :ascii\_only option with a true value is given, they escape all
12
+ non-ASCII and control characters with \uXXXX escape sequences, and support
13
+ UTF-16 surrogate pairs in order to be able to generate the whole range of
14
+ unicode code points.
15
+
16
+ All strings, that are to be encoded as JSON strings, should be UTF-8 byte
17
+ sequences on the Ruby side. To encode raw binary strings, that aren't UTF-8
18
+ encoded, please use the to\_json\_raw\_object method of String (which produces
19
+ an object, that contains a byte array) and decode the result on the receiving
20
+ endpoint.
21
+
22
+ ## Installation
23
+
24
+ It's recommended to use the extension variant of JSON, because it's faster than
25
+ the pure ruby variant. If you cannot build it on your system, you can settle
26
+ for the latter.
27
+
28
+ Install the gem and add to the application's Gemfile by executing:
29
+
30
+ $ bundle add json
31
+
32
+ If bundler is not being used to manage dependencies, install the gem by executing:
33
+
34
+ $ gem install json
35
+
36
+
37
+ There is also a pure ruby json only variant of the gem, that can be installed
38
+ with:
39
+
40
+ $ gem install json_pure
41
+
42
+ ## Usage
43
+
44
+ To use JSON you can
45
+
46
+ ```ruby
47
+ require 'json'
48
+ ```
49
+
50
+ to load the installed variant (either the extension `'json'` or the pure
51
+ variant `'json_pure'`). If you have installed the extension variant, you can
52
+ pick either the extension variant or the pure variant by typing
53
+
54
+ ```ruby
55
+ require 'json/ext'
56
+ ```
57
+
58
+ or
59
+
60
+ ```ruby
61
+ require 'json/pure'
62
+ ```
63
+
64
+ Now you can parse a JSON document into a ruby data structure by calling
65
+
66
+ ```ruby
67
+ JSON.parse(document)
68
+ ```
69
+
70
+ If you want to generate a JSON document from a ruby data structure call
71
+ ```ruby
72
+ JSON.generate(data)
73
+ ```
74
+
75
+ You can also use the `pretty_generate` method (which formats the output more
76
+ verbosely and nicely) or `fast_generate` (which doesn't do any of the security
77
+ checks generate performs, e. g. nesting deepness checks).
78
+
79
+ ## Handling arbitrary types
80
+
81
+ > [!CAUTION]
82
+ > You should never use `JSON.unsafe_load` nor `JSON.parse(str, create_additions: true)` to parse untrusted user input,
83
+ > as it can lead to remove code execution vulnerabilities.
84
+
85
+ To create a JSON document from a ruby data structure, you can call
86
+ `JSON.generate` like that:
87
+
88
+ ```ruby
89
+ json = JSON.generate [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
90
+ # => "[1,2,{\"a\":3.141},false,true,null,\"4..10\"]"
91
+ ```
92
+
93
+ To get back a ruby data structure from a JSON document, you have to call
94
+ JSON.parse on it:
95
+
96
+ ```ruby
97
+ JSON.parse json
98
+ # => [1, 2, {"a"=>3.141}, false, true, nil, "4..10"]
99
+ ```
100
+
101
+ Note, that the range from the original data structure is a simple
102
+ string now. The reason for this is, that JSON doesn't support ranges
103
+ or arbitrary classes. In this case the json library falls back to call
104
+ `Object#to_json`, which is the same as `#to_s.to_json`.
105
+
106
+ It's possible to add JSON support serialization to arbitrary classes by
107
+ simply implementing a more specialized version of the `#to_json method`, that
108
+ should return a JSON object (a hash converted to JSON with `#to_json`) like
109
+ this (don't forget the `*a` for all the arguments):
110
+
111
+ ```ruby
112
+ class Range
113
+ def to_json(*a)
114
+ {
115
+ 'json_class' => self.class.name, # = 'Range'
116
+ 'data' => [ first, last, exclude_end? ]
117
+ }.to_json(*a)
118
+ end
119
+ end
120
+ ```
121
+
122
+ The hash key `json_class` is the class, that will be asked to deserialise the
123
+ JSON representation later. In this case it's `Range`, but any namespace of
124
+ the form `A::B` or `::A::B` will do. All other keys are arbitrary and can be
125
+ used to store the necessary data to configure the object to be deserialised.
126
+
127
+ If the key `json_class` is found in a JSON object, the JSON parser checks
128
+ if the given class responds to the `json_create` class method. If so, it is
129
+ called with the JSON object converted to a Ruby hash. So a range can
130
+ be deserialised by implementing `Range.json_create` like this:
131
+
132
+ ```ruby
133
+ class Range
134
+ def self.json_create(o)
135
+ new(*o['data'])
136
+ end
137
+ end
138
+ ```
139
+
140
+ Now it possible to serialise/deserialise ranges as well:
141
+
142
+ ```ruby
143
+ json = JSON.generate [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
144
+ # => "[1,2,{\"a\":3.141},false,true,null,{\"json_class\":\"Range\",\"data\":[4,10,false]}]"
145
+ JSON.parse json
146
+ # => [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
147
+ json = JSON.generate [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
148
+ # => "[1,2,{\"a\":3.141},false,true,null,{\"json_class\":\"Range\",\"data\":[4,10,false]}]"
149
+ JSON.unsafe_load json
150
+ # => [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
151
+ ```
152
+
153
+ `JSON.generate` always creates the shortest possible string representation of a
154
+ ruby data structure in one line. This is good for data storage or network
155
+ protocols, but not so good for humans to read. Fortunately there's also
156
+ `JSON.pretty_generate` (or `JSON.pretty_generate`) that creates a more readable
157
+ output:
158
+
159
+ ```ruby
160
+ puts JSON.pretty_generate([1, 2, {"a"=>3.141}, false, true, nil, 4..10])
161
+ [
162
+ 1,
163
+ 2,
164
+ {
165
+ "a": 3.141
166
+ },
167
+ false,
168
+ true,
169
+ null,
170
+ {
171
+ "json_class": "Range",
172
+ "data": [
173
+ 4,
174
+ 10,
175
+ false
176
+ ]
177
+ }
178
+ ]
179
+ ```
180
+
181
+ There are also the methods `Kernel#j` for generate, and `Kernel#jj` for
182
+ `pretty_generate` output to the console, that work analogous to Core Ruby's `p` and
183
+ the `pp` library's `pp` methods.
184
+
185
+ ## Development
186
+
187
+ ### Release
188
+
189
+ Update the `lib/json/version.rb` file.
190
+
191
+ ```
192
+ rbenv shell 2.6.5
193
+ rake build
194
+ gem push pkg/json-2.3.0.gem
195
+
196
+ rbenv shell jruby-9.2.9.0
197
+ rake build
198
+ gem push pkg/json-2.3.0-java.gem
199
+ ```
200
+
201
+ ## Author
202
+
203
+ Florian Frank <mailto:flori@ping.de>
204
+
205
+ ## License
206
+
207
+ Ruby License, see https://www.ruby-lang.org/en/about/license.txt.
208
+
209
+ ## Download
210
+
211
+ The latest version of this library can be downloaded at
212
+
213
+ * https://rubygems.org/gems/json
214
+
215
+ Online Documentation should be located at
216
+
217
+ * https://www.rubydoc.info/gems/json
218
+
219
+ [Ragel]: http://www.colm.net/open-source/ragel/
data/json_pure.gemspec ADDED
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ version = File.foreach(File.join(__dir__, "lib/json/version.rb")) do |line|
4
+ /^\s*VERSION\s*=\s*'(.*)'/ =~ line and break $1
5
+ end rescue nil
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "json_pure"
9
+ s.version = version
10
+
11
+ s.summary = "JSON Implementation for Ruby"
12
+ s.description = "This is a JSON implementation in pure Ruby."
13
+ s.licenses = ["Ruby"]
14
+ s.authors = ["Florian Frank"]
15
+ s.email = "flori@ping.de"
16
+
17
+ s.extra_rdoc_files = ["README.md"]
18
+ s.rdoc_options = ["--title", "JSON implementation for ruby", "--main", "README.md"]
19
+ s.files = [
20
+ "CHANGES.md",
21
+ "COPYING",
22
+ "BSDL",
23
+ "LEGAL",
24
+ "README.md",
25
+ "json_pure.gemspec",
26
+ "lib/json/pure.rb",
27
+ ]
28
+ s.homepage = "https://ruby.github.io/json"
29
+ s.metadata = {
30
+ 'bug_tracker_uri' => 'https://github.com/ruby/json/issues',
31
+ 'changelog_uri' => 'https://github.com/ruby/json/blob/master/CHANGES.md',
32
+ 'documentation_uri' => 'https://ruby.github.io/json/doc/index.html',
33
+ 'homepage_uri' => s.homepage,
34
+ 'source_code_uri' => 'https://github.com/ruby/json',
35
+ 'wiki_uri' => 'https://github.com/ruby/json/wiki'
36
+ }
37
+
38
+ s.required_ruby_version = Gem::Requirement.new(">= 2.7")
39
+ end
data/lib/json/pure.rb CHANGED
@@ -1,77 +1,4 @@
1
- require 'json/common'
2
- require 'json/pure/parser'
3
- require 'json/pure/generator'
1
+ # frozen_string_literal: true
4
2
 
5
- module JSON
6
- begin
7
- require 'iconv'
8
- # An iconv instance to convert from UTF8 to UTF16 Big Endian.
9
- UTF16toUTF8 = Iconv.new('utf-8', 'utf-16be') # :nodoc:
10
- # An iconv instance to convert from UTF16 Big Endian to UTF8.
11
- UTF8toUTF16 = Iconv.new('utf-16be', 'utf-8') # :nodoc:
12
- UTF8toUTF16.iconv('no bom')
13
- rescue LoadError
14
- raise MissingUnicodeSupport,
15
- "iconv couldn't be loaded, which is required for UTF-8/UTF-16 conversions"
16
- rescue Errno::EINVAL, Iconv::InvalidEncoding
17
- # Iconv doesn't support big endian utf-16. Let's try to hack this manually
18
- # into the converters.
19
- begin
20
- old_verbose, $VERBSOSE = $VERBOSE, nil
21
- # An iconv instance to convert from UTF8 to UTF16 Big Endian.
22
- UTF16toUTF8 = Iconv.new('utf-8', 'utf-16') # :nodoc:
23
- # An iconv instance to convert from UTF16 Big Endian to UTF8.
24
- UTF8toUTF16 = Iconv.new('utf-16', 'utf-8') # :nodoc:
25
- UTF8toUTF16.iconv('no bom')
26
- if UTF8toUTF16.iconv("\xe2\x82\xac") == "\xac\x20"
27
- swapper = Class.new do
28
- def initialize(iconv) # :nodoc:
29
- @iconv = iconv
30
- end
31
-
32
- def iconv(string) # :nodoc:
33
- result = @iconv.iconv(string)
34
- JSON.swap!(result)
35
- end
36
- end
37
- UTF8toUTF16 = swapper.new(UTF8toUTF16) # :nodoc:
38
- end
39
- if UTF16toUTF8.iconv("\xac\x20") == "\xe2\x82\xac"
40
- swapper = Class.new do
41
- def initialize(iconv) # :nodoc:
42
- @iconv = iconv
43
- end
44
-
45
- def iconv(string) # :nodoc:
46
- string = JSON.swap!(string.dup)
47
- @iconv.iconv(string)
48
- end
49
- end
50
- UTF16toUTF8 = swapper.new(UTF16toUTF8) # :nodoc:
51
- end
52
- rescue Errno::EINVAL, Iconv::InvalidEncoding
53
- raise MissingUnicodeSupport, "iconv doesn't seem to support UTF-8/UTF-16 conversions"
54
- ensure
55
- $VERBOSE = old_verbose
56
- end
57
- end
58
-
59
- # Swap consecutive bytes of _string_ in place.
60
- def self.swap!(string) # :nodoc:
61
- 0.upto(string.size / 2) do |i|
62
- break unless string[2 * i + 1]
63
- string[2 * i], string[2 * i + 1] = string[2 * i + 1], string[2 * i]
64
- end
65
- string
66
- end
67
-
68
- # This module holds all the modules/classes that implement JSON's
69
- # functionality in pure ruby.
70
- module Pure
71
- $DEBUG and warn "Using pure library for JSON."
72
- JSON.parser = Parser
73
- JSON.generator = Generator
74
- end
75
-
76
- JSON_LOADED = true
77
- end
3
+ warn "`json_pure` is deprecated and has no effect, just use `json`"
4
+ require "json"
metadata CHANGED
@@ -1,180 +1,60 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: json_pure
3
- version: !ruby/object:Gem::Version
4
- version: 1.4.6
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.8.1
5
5
  platform: ruby
6
- authors:
6
+ authors:
7
7
  - Florian Frank
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
-
12
- date: 2010-08-09 00:00:00 +02:00
13
- default_executable: edit_json.rb
11
+ date: 2024-11-05 00:00:00.000000000 Z
14
12
  dependencies: []
15
-
16
13
  description: This is a JSON implementation in pure Ruby.
17
14
  email: flori@ping.de
18
- executables:
19
- - edit_json.rb
20
- - prettify_json.rb
15
+ executables: []
21
16
  extensions: []
22
-
23
- extra_rdoc_files:
24
- - README
25
- files:
26
- - CHANGES
27
- - bin/edit_json.rb
28
- - bin/prettify_json.rb
29
- - VERSION
30
- - GPL
31
- - TODO
32
- - README
33
- - benchmarks/ohai.json
34
- - benchmarks/parser_benchmark.rb
35
- - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure.log
36
- - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkComparison.log
37
- - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser.dat
38
- - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe.dat
39
- - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser.dat
40
- - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast.dat
41
- - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_fast-autocorrelation.dat
42
- - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure.log
43
- - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt#parser-autocorrelation.dat
44
- - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator-autocorrelation.dat
45
- - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt.log
46
- - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast-autocorrelation.dat
47
- - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_fast.dat
48
- - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser.dat
49
- - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty-autocorrelation.dat
50
- - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser-autocorrelation.dat
51
- - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty.dat
52
- - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails.log
53
- - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkExt.log
54
- - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails.log
55
- - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkComparison.log
56
- - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe.dat
57
- - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkRails#generator.dat
58
- - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_safe-autocorrelation.dat
59
- - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_pretty.dat
60
- - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML.log
61
- - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkYAML#parser-autocorrelation.dat
62
- - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkExt#generator_pretty-autocorrelation.dat
63
- - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkRails#parser-autocorrelation.dat
64
- - benchmarks/data-p4-3GHz-ruby18/ParserBenchmarkPure#parser.dat
65
- - benchmarks/data-p4-3GHz-ruby18/GeneratorBenchmarkPure#generator_safe-autocorrelation.dat
66
- - benchmarks/generator2_benchmark.rb
67
- - benchmarks/generator_benchmark.rb
68
- - benchmarks/parser2_benchmark.rb
69
- - benchmarks/ohai.ruby
70
- - ext/json/ext/generator/extconf.rb
71
- - ext/json/ext/generator/generator.c
72
- - ext/json/ext/generator/generator.h
73
- - ext/json/ext/parser/extconf.rb
74
- - ext/json/ext/parser/parser.rl
75
- - ext/json/ext/parser/parser.h
76
- - ext/json/ext/parser/parser.c
77
- - Rakefile
78
- - tools/fuzz.rb
79
- - tools/server.rb
80
- - lib/json.rb
81
- - lib/json/json.xpm
82
- - lib/json/Key.xpm
83
- - lib/json/String.xpm
84
- - lib/json/Numeric.xpm
85
- - lib/json/Hash.xpm
86
- - lib/json/add/rails.rb
87
- - lib/json/add/core.rb
88
- - lib/json/common.rb
89
- - lib/json/Array.xpm
90
- - lib/json/FalseClass.xpm
91
- - lib/json/pure/generator.rb
92
- - lib/json/pure/parser.rb
93
- - lib/json/TrueClass.xpm
94
- - lib/json/pure.rb
95
- - lib/json/version.rb
96
- - lib/json/ext.rb
97
- - lib/json/editor.rb
98
- - lib/json/NilClass.xpm
99
- - data/example.json
100
- - data/index.html
101
- - data/prototype.js
102
- - tests/test_json_encoding.rb
103
- - tests/test_json_addition.rb
104
- - tests/fixtures/pass16.json
105
- - tests/fixtures/fail4.json
106
- - tests/fixtures/fail1.json
107
- - tests/fixtures/fail28.json
108
- - tests/fixtures/fail8.json
109
- - tests/fixtures/fail19.json
110
- - tests/fixtures/pass2.json
111
- - tests/fixtures/pass26.json
112
- - tests/fixtures/pass1.json
113
- - tests/fixtures/fail3.json
114
- - tests/fixtures/fail20.json
115
- - tests/fixtures/pass3.json
116
- - tests/fixtures/pass15.json
117
- - tests/fixtures/fail12.json
118
- - tests/fixtures/fail13.json
119
- - tests/fixtures/fail22.json
120
- - tests/fixtures/fail24.json
121
- - tests/fixtures/fail9.json
122
- - tests/fixtures/fail2.json
123
- - tests/fixtures/fail14.json
124
- - tests/fixtures/fail6.json
125
- - tests/fixtures/fail21.json
126
- - tests/fixtures/fail7.json
127
- - tests/fixtures/pass17.json
128
- - tests/fixtures/fail11.json
129
- - tests/fixtures/fail25.json
130
- - tests/fixtures/fail5.json
131
- - tests/fixtures/fail18.json
132
- - tests/fixtures/fail27.json
133
- - tests/fixtures/fail10.json
134
- - tests/fixtures/fail23.json
135
- - tests/test_json_rails.rb
136
- - tests/test_json.rb
137
- - tests/test_json_generate.rb
138
- - tests/test_json_unicode.rb
139
- - tests/test_json_fixtures.rb
17
+ extra_rdoc_files:
18
+ - README.md
19
+ files:
20
+ - BSDL
21
+ - CHANGES.md
140
22
  - COPYING
141
- - install.rb
142
- has_rdoc: true
143
- homepage: http://flori.github.com/json
144
- licenses: []
145
-
146
- post_install_message:
147
- rdoc_options:
148
- - --title
149
- - JSON implemention for ruby
150
- - --main
151
- - README
152
- require_paths:
23
+ - LEGAL
24
+ - README.md
25
+ - json_pure.gemspec
26
+ - lib/json/pure.rb
27
+ homepage: https://ruby.github.io/json
28
+ licenses:
29
+ - Ruby
30
+ metadata:
31
+ bug_tracker_uri: https://github.com/ruby/json/issues
32
+ changelog_uri: https://github.com/ruby/json/blob/master/CHANGES.md
33
+ documentation_uri: https://ruby.github.io/json/doc/index.html
34
+ homepage_uri: https://ruby.github.io/json
35
+ source_code_uri: https://github.com/ruby/json
36
+ wiki_uri: https://github.com/ruby/json/wiki
37
+ post_install_message:
38
+ rdoc_options:
39
+ - "--title"
40
+ - JSON implementation for ruby
41
+ - "--main"
42
+ - README.md
43
+ require_paths:
153
44
  - lib
154
- required_ruby_version: !ruby/object:Gem::Requirement
155
- requirements:
45
+ required_ruby_version: !ruby/object:Gem::Requirement
46
+ requirements:
156
47
  - - ">="
157
- - !ruby/object:Gem::Version
158
- version: "0"
159
- version:
160
- required_rubygems_version: !ruby/object:Gem::Requirement
161
- requirements:
48
+ - !ruby/object:Gem::Version
49
+ version: '2.7'
50
+ required_rubygems_version: !ruby/object:Gem::Requirement
51
+ requirements:
162
52
  - - ">="
163
- - !ruby/object:Gem::Version
164
- version: "0"
165
- version:
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
166
55
  requirements: []
167
-
168
- rubyforge_project: json
169
- rubygems_version: 1.3.5
170
- signing_key:
171
- specification_version: 3
56
+ rubygems_version: 3.5.11
57
+ signing_key:
58
+ specification_version: 4
172
59
  summary: JSON Implementation for Ruby
173
- test_files:
174
- - tests/test_json_encoding.rb
175
- - tests/test_json_addition.rb
176
- - tests/test_json_rails.rb
177
- - tests/test_json.rb
178
- - tests/test_json_generate.rb
179
- - tests/test_json_unicode.rb
180
- - tests/test_json_fixtures.rb
60
+ test_files: []