oj 3.11.3 → 3.11.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/ext/oj/buf.h +34 -38
- data/ext/oj/cache8.c +59 -62
- data/ext/oj/cache8.h +8 -7
- data/ext/oj/circarray.c +33 -35
- data/ext/oj/circarray.h +11 -9
- data/ext/oj/code.c +170 -174
- data/ext/oj/code.h +21 -20
- data/ext/oj/compat.c +159 -166
- data/ext/oj/custom.c +802 -851
- data/ext/oj/dump.c +766 -778
- data/ext/oj/dump.h +49 -51
- data/ext/oj/dump_compat.c +1 -0
- data/ext/oj/dump_leaf.c +116 -157
- data/ext/oj/dump_object.c +609 -628
- data/ext/oj/dump_strict.c +318 -327
- data/ext/oj/encode.h +3 -4
- data/ext/oj/err.c +39 -25
- data/ext/oj/err.h +24 -15
- data/ext/oj/extconf.rb +2 -1
- data/ext/oj/fast.c +1008 -1038
- data/ext/oj/hash.c +62 -66
- data/ext/oj/hash.h +7 -6
- data/ext/oj/hash_test.c +450 -443
- data/ext/oj/mimic_json.c +405 -401
- data/ext/oj/object.c +559 -528
- data/ext/oj/odd.c +123 -128
- data/ext/oj/odd.h +27 -25
- data/ext/oj/oj.c +1121 -921
- data/ext/oj/oj.h +286 -298
- data/ext/oj/parse.c +938 -930
- data/ext/oj/parse.h +70 -69
- data/ext/oj/rails.c +836 -839
- data/ext/oj/rails.h +7 -7
- data/ext/oj/reader.c +135 -140
- data/ext/oj/reader.h +66 -79
- data/ext/oj/resolve.c +43 -43
- data/ext/oj/resolve.h +3 -2
- data/ext/oj/rxclass.c +67 -68
- data/ext/oj/rxclass.h +12 -10
- data/ext/oj/saj.c +451 -479
- data/ext/oj/scp.c +93 -103
- data/ext/oj/sparse.c +770 -730
- data/ext/oj/stream_writer.c +120 -149
- data/ext/oj/strict.c +71 -86
- data/ext/oj/string_writer.c +198 -243
- data/ext/oj/trace.c +29 -33
- data/ext/oj/trace.h +14 -11
- data/ext/oj/util.c +103 -103
- data/ext/oj/util.h +3 -2
- data/ext/oj/val_stack.c +47 -47
- data/ext/oj/val_stack.h +79 -86
- data/ext/oj/wab.c +291 -309
- data/lib/oj/bag.rb +1 -0
- data/lib/oj/mimic.rb +0 -12
- data/lib/oj/version.rb +1 -1
- data/test/activerecord/result_test.rb +7 -2
- data/test/foo.rb +35 -32
- data/test/test_scp.rb +1 -1
- metadata +2 -2
data/lib/oj/bag.rb
CHANGED
data/lib/oj/mimic.rb
CHANGED
@@ -133,18 +133,6 @@ module Oj
|
|
133
133
|
end
|
134
134
|
end
|
135
135
|
|
136
|
-
Date.class_eval do
|
137
|
-
# Both the JSON gem and Rails monkey patch as_json. Let them battle it out.
|
138
|
-
unless defined?(self.as_json)
|
139
|
-
def as_json(*)
|
140
|
-
{ JSON.create_id => 'Date', 'y' => year, 'm' => month, 'd' => day, 'sg' => start }
|
141
|
-
end
|
142
|
-
end
|
143
|
-
def self.json_create(h)
|
144
|
-
civil(h['y'], h['m'], h['d'], h['sg'])
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
136
|
DateTime.class_eval do
|
149
137
|
# Both the JSON gem and Rails monkey patch as_json. Let them battle it out.
|
150
138
|
unless defined?(self.as_json)
|
data/lib/oj/version.rb
CHANGED
@@ -21,7 +21,12 @@ class ActiveRecordResultTest < Minitest::Test
|
|
21
21
|
["row 3 col 1", "row 3 col 2"],
|
22
22
|
])
|
23
23
|
#puts "*** result: #{Oj.dump(result, indent: 2)}"
|
24
|
-
|
25
|
-
|
24
|
+
json_result = if ActiveRecord.version >= Gem::Version.new("6")
|
25
|
+
result.to_a
|
26
|
+
else
|
27
|
+
result.to_hash
|
28
|
+
end
|
29
|
+
|
30
|
+
assert_equal Oj.dump(result, mode: :rails), Oj.dump(json_result)
|
26
31
|
end
|
27
32
|
end
|
data/test/foo.rb
CHANGED
@@ -6,47 +6,50 @@ $oj_dir = File.dirname(File.expand_path(File.dirname(__FILE__)))
|
|
6
6
|
$: << File.join($oj_dir, dir)
|
7
7
|
end
|
8
8
|
|
9
|
-
require 'json'
|
10
|
-
|
11
|
-
t = [Time.now.utc]
|
12
|
-
|
13
|
-
puts "t.to_json - #{t.to_json}"
|
14
|
-
|
15
|
-
puts "--- active support"
|
16
|
-
|
17
|
-
require 'active_support'
|
18
|
-
require "active_support/json"
|
19
|
-
|
20
|
-
ActiveSupport::JSON::Encoding.use_standard_json_time_format = false
|
21
|
-
|
22
|
-
puts "t.as_json - #{t.as_json}"
|
23
|
-
puts "t.to_json - #{t.to_json}"
|
24
|
-
|
25
9
|
require 'oj'
|
26
10
|
|
27
|
-
|
11
|
+
class Foo
|
12
|
+
def initialize
|
13
|
+
@x = 123
|
14
|
+
end
|
15
|
+
|
16
|
+
def xto_json(opt=nil, options=nil)
|
17
|
+
"---to_json---"
|
18
|
+
end
|
19
|
+
end
|
28
20
|
|
29
|
-
|
21
|
+
class Bar < Foo
|
22
|
+
def initialize
|
23
|
+
@x = 321
|
24
|
+
end
|
25
|
+
end
|
30
26
|
|
31
|
-
|
32
|
-
|
27
|
+
foo = Foo.new
|
28
|
+
bar = Bar.new
|
33
29
|
|
34
|
-
|
30
|
+
require 'json'
|
35
31
|
|
36
|
-
|
32
|
+
puts "JSON: #{JSON.generate(foo)}"
|
33
|
+
puts "to_json: #{foo.to_json}"
|
34
|
+
puts "bar JSON: #{JSON.generate(bar)}"
|
35
|
+
puts "bar to_json: #{bar.to_json}"
|
37
36
|
|
38
|
-
|
37
|
+
m = bar.method('to_json')
|
38
|
+
puts "*** method: #{m} owner: #{m.owner.name}"
|
39
39
|
|
40
|
-
|
41
|
-
require
|
40
|
+
puts "---- rails"
|
41
|
+
require 'rails'
|
42
42
|
|
43
|
-
|
43
|
+
m = bar.method('to_json')
|
44
|
+
puts "*** method: #{m} owner: #{m.owner} params: #{m.parameters}"
|
44
45
|
|
45
|
-
puts "
|
46
|
-
puts "
|
46
|
+
puts "JSON: #{JSON.generate(foo)}"
|
47
|
+
puts "to_json: #{foo.to_json}"
|
47
48
|
|
48
|
-
puts "
|
49
|
-
Oj.
|
49
|
+
puts "---- Oj.mimic_JSON"
|
50
|
+
Oj.mimic_JSON()
|
51
|
+
puts "Oj JSON: #{JSON.generate(foo)}"
|
52
|
+
puts "Oj to_json: #{foo.to_json}"
|
50
53
|
|
51
|
-
|
52
|
-
puts "
|
54
|
+
m = bar.method('to_json')
|
55
|
+
puts "*** method: #{m} owner: #{m.owner} params: #{m.parameters}"
|
data/test/test_scp.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oj
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.11.
|
4
|
+
version: 3.11.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Ohler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|