oj 3.7.12 → 3.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -2
- data/ext/oj/custom.c +74 -48
- data/ext/oj/dump.c +46 -26
- data/ext/oj/dump.h +2 -0
- data/ext/oj/dump_compat.c +13 -9
- data/ext/oj/extconf.rb +1 -0
- data/ext/oj/mimic_json.c +7 -2
- data/ext/oj/object.c +8 -5
- data/ext/oj/oj.c +37 -27
- data/ext/oj/oj.h +8 -4
- data/ext/oj/parse.c +6 -1
- data/ext/oj/rails.c +10 -0
- data/ext/oj/resolve.c +3 -3
- data/ext/oj/sparse.c +6 -2
- data/ext/oj/string_writer.c +25 -3
- data/ext/oj/util.c +5 -5
- data/ext/oj/val_stack.c +9 -9
- data/ext/oj/val_stack.h +9 -9
- data/lib/oj/json.rb +1 -1
- data/lib/oj/version.rb +1 -1
- data/pages/Modes.md +3 -2
- data/pages/Options.md +23 -2
- data/pages/Security.md +1 -1
- data/test/bar.rb +25 -0
- data/test/foo.rb +14 -26
- data/test/test_custom.rb +99 -2
- data/test/test_various.rb +2 -0
- data/test/zoo.rb +13 -0
- metadata +71 -71
- data/test/big.rb +0 -15
- data/test/mem.rb +0 -35
data/test/big.rb
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
#require 'active_support'
|
2
|
-
#require 'active_support/core_ext'
|
3
|
-
#require 'active_support/json'
|
4
|
-
require 'oj'
|
5
|
-
|
6
|
-
#Oj.optimize_rails
|
7
|
-
Oj.mimic_JSON
|
8
|
-
|
9
|
-
h = {:type=>:record, :name=>:group, :namespace=>"com.salsify.identity", :fields=>[{:name=>"id", :type=>{:name=>:salsify_uuid, :type=>:fixed, :namespace=>"com.salsify", :size=>38}}, {:name=>"type", :type=>"string", :default=>"groups"}, {:name=>"external_id", :type=>[:null, "string"], :default=>nil}, {:name=>"created_at", :type=>{:type=>"long", :logicalType=>"timestamp-micros"}}, {:name=>"updated_at", :type=>{:type=>"long", :logicalType=>"timestamp-micros"}}, {:name=>"name", :type=>"string"}, {:name=>"policy", :type=>[:null, {:type=>:record, :name=>:policy, :namespace=>"com.salsify.security", :fields=>[{:name=>"created_at", :type=>{:type=>"long", :logicalType=>"timestamp-micros"}}, {:name=>"updated_at", :type=>{:type=>"long", :logicalType=>"timestamp-micros"}}, {:name=>"id", :type=>"com.salsify.salsify_uuid"}, {:name=>"type", :type=>"string", :default=>"policies"}, {:name=>"external_id", :type=>[:null, "string"], :default=>nil}, {:name=>"name", :type=>"string"}, {:name=>"statements", :type=>{:type=>:array, :items=>{:type=>:record, :name=>:statement, :namespace=>"com.salsify.security", :fields=>[{:name=>"created_at", :type=>{:type=>"long", :logicalType=>"timestamp-micros"}}, {:name=>"updated_at", :type=>{:type=>"long", :logicalType=>"timestamp-micros"}}, {:name=>"id", :type=>"com.salsify.salsify_uuid"}, {:name=>"type", :type=>"string", :default=>"statements"}, {:name=>"external_id", :type=>[:null, "string"], :default=>nil}, {:name=>"action", :type=>{:name=>"__statement_action_enum", :type=>:enum, :namespace=>"com.salsify.security", :symbols=>[:manage, :read]}}, {:name=>"resource", :type=>{:name=>"__statement_resource_enum", :type=>:enum, :namespace=>"com.salsify.security", :symbols=>[:product, :digital_asset]}}, {:name=>"conditions", :type=>{:type=>:array, :items=>{:type=>:record, :name=>:condition, :namespace=>"com.salsify.security", :fields=>[{:name=>"created_at", :type=>{:type=>"long", :logicalType=>"timestamp-micros"}}, {:name=>"updated_at", :type=>{:type=>"long", :logicalType=>"timestamp-micros"}}, {:name=>"id", :type=>"com.salsify.salsify_uuid"}, {:name=>"type", :type=>"string", :default=>"conditions"}, {:name=>"external_id", :type=>[:null, "string"], :default=>nil}, {:name=>"operator", :type=>{:name=>"__condition_operator_enum", :type=>:enum, :namespace=>"com.salsify.security", :symbols=>[:equals]}}, {:name=>"attribute_type", :type=>{:name=>"__condition_attribute_type_enum", :type=>:enum, :namespace=>"com.salsify.security", :symbols=>[:resource]}}, {:name=>"value", :type=>"string"}, {:name=>"attribute", :type=>[:null, {:type=>:record, :name=>:reference, :namespace=>"com.salsify", :fields=>[{:name=>"id", :type=>"com.salsify.salsify_uuid"}, {:name=>"type", :type=>"string", :doc=>"snake_case, plural name for the resource type"}, {:name=>"external_id", :type=>[:null, "string"], :default=>nil}]}], :default=>nil}, {:name=>"broken", :type=>[:null, "boolean"], :default=>nil}]}}}]}}}]}], :default=>nil}]}
|
10
|
-
|
11
|
-
#Oj.dump(h)
|
12
|
-
puts JSON.pretty_generate(h)
|
13
|
-
#puts JSON.fast_generate(h)
|
14
|
-
#puts JSON.generate(h)
|
15
|
-
|
data/test/mem.rb
DELETED
@@ -1,35 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
$: << '.'
|
4
|
-
$: << '../lib'
|
5
|
-
$: << '../ext'
|
6
|
-
|
7
|
-
require 'objspace'
|
8
|
-
require 'oj'
|
9
|
-
require 'json'
|
10
|
-
require 'get_process_mem'
|
11
|
-
|
12
|
-
def record_allocation
|
13
|
-
GC.start
|
14
|
-
GC.start
|
15
|
-
|
16
|
-
mem = GetProcessMem.new
|
17
|
-
puts "Before - Process Memory: #{mem.mb} mb"
|
18
|
-
puts "Before - Objects count: #{ObjectSpace.each_object.count}"
|
19
|
-
puts "Before - Symbols count: #{Symbol.all_symbols.size}"
|
20
|
-
|
21
|
-
yield
|
22
|
-
|
23
|
-
GC.start
|
24
|
-
GC.start
|
25
|
-
GC.start
|
26
|
-
|
27
|
-
puts "After - Process Memory: #{mem.mb} mb"
|
28
|
-
puts "After - Objects count: #{ObjectSpace.each_object.count}"
|
29
|
-
puts "After - Symbols count: #{Symbol.all_symbols.size}"
|
30
|
-
end
|
31
|
-
|
32
|
-
record_allocation do
|
33
|
-
data = 1_000_000.times.map { |i| "string_number_#{i}".to_sym } # array of symbols
|
34
|
-
Oj.dump(data, mode: :rails)
|
35
|
-
end
|