json 2.10.2 → 2.19.9
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 +4 -4
- data/CHANGES.md +205 -7
- data/LEGAL +12 -0
- data/README.md +43 -1
- data/ext/json/ext/fbuffer/fbuffer.h +140 -86
- data/ext/json/ext/generator/extconf.rb +8 -0
- data/ext/json/ext/generator/generator.c +787 -616
- data/ext/json/ext/json.h +116 -0
- data/ext/json/ext/parser/extconf.rb +11 -3
- data/ext/json/ext/parser/parser.c +974 -703
- data/ext/json/ext/simd/conf.rb +24 -0
- data/ext/json/ext/simd/simd.h +208 -0
- data/ext/json/ext/vendor/fpconv.c +480 -0
- data/ext/json/ext/vendor/jeaiii-ltoa.h +267 -0
- data/ext/json/ext/vendor/ryu.h +819 -0
- data/json.gemspec +2 -3
- data/lib/json/add/core.rb +1 -0
- data/lib/json/add/string.rb +35 -0
- data/lib/json/common.rb +374 -188
- data/lib/json/ext/generator/state.rb +11 -14
- data/lib/json/ext.rb +2 -2
- data/lib/json/generic_object.rb +0 -8
- data/lib/json/truffle_ruby/generator.rb +137 -72
- data/lib/json/version.rb +1 -1
- data/lib/json.rb +90 -2
- metadata +66 -57
data/json.gemspec
CHANGED
|
@@ -44,15 +44,14 @@ spec = Gem::Specification.new do |s|
|
|
|
44
44
|
"LEGAL",
|
|
45
45
|
"README.md",
|
|
46
46
|
"json.gemspec",
|
|
47
|
-
|
|
48
|
-
]
|
|
47
|
+
] + Dir.glob("lib/**/*.rb", base: File.expand_path("..", __FILE__))
|
|
49
48
|
|
|
50
49
|
if java_ext
|
|
51
50
|
s.platform = 'java'
|
|
52
51
|
s.files += Dir["lib/json/ext/**/*.jar"]
|
|
53
52
|
else
|
|
54
53
|
s.extensions = Dir["ext/json/**/extconf.rb"]
|
|
55
|
-
s.files += Dir["ext/json/**/*.{c,h}"]
|
|
54
|
+
s.files += Dir["ext/json/**/*.{c,h,rb}"]
|
|
56
55
|
end
|
|
57
56
|
end
|
|
58
57
|
|
data/lib/json/add/core.rb
CHANGED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
unless defined?(::JSON::JSON_LOADED) and ::JSON::JSON_LOADED
|
|
3
|
+
require 'json'
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
class String
|
|
7
|
+
# call-seq: json_create(o)
|
|
8
|
+
#
|
|
9
|
+
# Raw Strings are JSON Objects (the raw bytes are stored in an array for the
|
|
10
|
+
# key "raw"). The Ruby String can be created by this class method.
|
|
11
|
+
def self.json_create(object)
|
|
12
|
+
object["raw"].pack("C*")
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
# call-seq: to_json_raw_object()
|
|
16
|
+
#
|
|
17
|
+
# This method creates a raw object hash, that can be nested into
|
|
18
|
+
# other data structures and will be generated as a raw string. This
|
|
19
|
+
# method should be used, if you want to convert raw strings to JSON
|
|
20
|
+
# instead of UTF-8 strings, e. g. binary data.
|
|
21
|
+
def to_json_raw_object
|
|
22
|
+
{
|
|
23
|
+
JSON.create_id => self.class.name,
|
|
24
|
+
"raw" => unpack("C*"),
|
|
25
|
+
}
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# call-seq: to_json_raw(*args)
|
|
29
|
+
#
|
|
30
|
+
# This method creates a JSON text from the result of a call to
|
|
31
|
+
# to_json_raw_object of this String.
|
|
32
|
+
def to_json_raw(...)
|
|
33
|
+
to_json_raw_object.to_json(...)
|
|
34
|
+
end
|
|
35
|
+
end
|