oj 3.7.1 → 3.7.2
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/ext/oj/parse.c +11 -3
- data/ext/oj/sparse.c +11 -3
- data/lib/oj/version.rb +1 -1
- data/test/bar.rb +17 -0
- data/test/foo.rb +67 -16
- data/test/test_scp.rb +1 -1
- data/test/test_various.rb +3 -1
- metadata +68 -70
- data/test/big.rb +0 -15
- data/test/mem.rb +0 -35
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6f32c75eebaa4589864b9f86babc4a75a50fcb8a332e729fae0efad8aa6e237c
|
4
|
+
data.tar.gz: 8babb9c5d3738f3e3e10cb821b4b1ec9d2a8b669152daef099a0637e53b9477f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d077e44e7422e57a3332926cfbe67a46311a4a005ca49bfce7a44b620b4a73d5d4c0d355885017ca3343eb0b63a2539e3609cdb2671d0b87f932101a2cdf3e7e
|
7
|
+
data.tar.gz: 674b27cecfb35ac204a2e51bd692364fd5c4235d0aeceb0988d37ec7fb1d25027f7a2b3b248425fdb7fa5311dde50299a655c1efa432ce42049c7cf3f162f2d1
|
data/ext/oj/parse.c
CHANGED
@@ -444,9 +444,13 @@ read_num(ParseInfo pi) {
|
|
444
444
|
}
|
445
445
|
if ('.' == *pi->cur) {
|
446
446
|
pi->cur++;
|
447
|
-
|
448
|
-
|
449
|
-
|
447
|
+
// A trailing . is not a valid decimal but if encountered allow it
|
448
|
+
// except when mimicing the JSON gem.
|
449
|
+
if (CompatMode == pi->options.mode) {
|
450
|
+
if (*pi->cur < '0' || '9' < *pi->cur) {
|
451
|
+
oj_set_error_at(pi, oj_parse_error_class, __FILE__, __LINE__, "not a number");
|
452
|
+
return;
|
453
|
+
}
|
450
454
|
}
|
451
455
|
for (; '0' <= *pi->cur && *pi->cur <= '9'; pi->cur++) {
|
452
456
|
int d = (*pi->cur - '0');
|
@@ -964,6 +968,9 @@ oj_pi_parse(int argc, VALUE *argv, ParseInfo pi, char *json, size_t len, int yie
|
|
964
968
|
if (0 != line) {
|
965
969
|
VALUE ec = rb_obj_class(rb_errinfo());
|
966
970
|
|
971
|
+
if (rb_eIOError != ec) {
|
972
|
+
goto CLEANUP;
|
973
|
+
}
|
967
974
|
if (rb_eArgError != ec && 0 != ec) {
|
968
975
|
err_class = ec;
|
969
976
|
}
|
@@ -987,6 +994,7 @@ oj_pi_parse(int argc, VALUE *argv, ParseInfo pi, char *json, size_t len, int yie
|
|
987
994
|
}
|
988
995
|
}
|
989
996
|
}
|
997
|
+
CLEANUP:
|
990
998
|
// proceed with cleanup
|
991
999
|
if (0 != pi->circ_array) {
|
992
1000
|
oj_circ_array_free(pi->circ_array);
|
data/ext/oj/sparse.c
CHANGED
@@ -456,8 +456,12 @@ read_num(ParseInfo pi) {
|
|
456
456
|
}
|
457
457
|
if ('.' == c) {
|
458
458
|
c = reader_get(&pi->rd);
|
459
|
-
|
460
|
-
|
459
|
+
// A trailing . is not a valid decimal but if encountered allow it
|
460
|
+
// except when mimicing the JSON gem.
|
461
|
+
if (CompatMode == pi->options.mode) {
|
462
|
+
if (c < '0' || '9' < c) {
|
463
|
+
oj_set_error_at(pi, oj_parse_error_class, __FILE__, __LINE__, "not a number");
|
464
|
+
}
|
461
465
|
}
|
462
466
|
for (; '0' <= c && c <= '9'; c = reader_get(&pi->rd)) {
|
463
467
|
int d = (c - '0');
|
@@ -838,7 +842,10 @@ oj_pi_sparse(int argc, VALUE *argv, ParseInfo pi, int fd) {
|
|
838
842
|
if (0 != line) {
|
839
843
|
VALUE ec = rb_obj_class(rb_errinfo());
|
840
844
|
|
841
|
-
|
845
|
+
if (rb_eIOError != ec) {
|
846
|
+
goto CLEANUP;
|
847
|
+
}
|
848
|
+
// Sometimes the class of the error is 0 which seems broken.
|
842
849
|
if (rb_eArgError != ec && 0 != ec) {
|
843
850
|
err_class = ec;
|
844
851
|
}
|
@@ -862,6 +869,7 @@ oj_pi_sparse(int argc, VALUE *argv, ParseInfo pi, int fd) {
|
|
862
869
|
}
|
863
870
|
}
|
864
871
|
}
|
872
|
+
CLEANUP:
|
865
873
|
// proceed with cleanup
|
866
874
|
if (0 != pi->circ_array) {
|
867
875
|
oj_circ_array_free(pi->circ_array);
|
data/lib/oj/version.rb
CHANGED
data/test/bar.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
3
|
+
|
4
|
+
$: << File.dirname(__FILE__)
|
5
|
+
$oj_dir = File.dirname(File.expand_path(File.dirname(__FILE__)))
|
6
|
+
%w(lib ext).each do |dir|
|
7
|
+
$: << File.join($oj_dir, dir)
|
8
|
+
end
|
9
|
+
|
10
|
+
require 'oj'
|
11
|
+
require 'tracer'
|
12
|
+
|
13
|
+
#Tracer.on
|
14
|
+
|
15
|
+
Oj.load_file(ARGV[0], mode: :strict) { |obj|
|
16
|
+
puts Oj.dump(obj, indent: 2)
|
17
|
+
}
|
data/test/foo.rb
CHANGED
@@ -1,32 +1,83 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# encoding: UTF-8
|
2
3
|
|
3
|
-
$: <<
|
4
|
-
|
5
|
-
|
4
|
+
$: << File.dirname(__FILE__)
|
5
|
+
$oj_dir = File.dirname(File.expand_path(File.dirname(__FILE__)))
|
6
|
+
%w(lib ext).each do |dir|
|
7
|
+
$: << File.join($oj_dir, dir)
|
8
|
+
end
|
6
9
|
|
7
10
|
require 'oj'
|
11
|
+
require 'tracer'
|
8
12
|
|
13
|
+
#Tracer.on
|
9
14
|
|
10
15
|
class MyParser
|
16
|
+
attr_accessor :enum
|
17
|
+
|
11
18
|
def initialize
|
12
|
-
@
|
13
|
-
|
19
|
+
@io = StringIO.new
|
20
|
+
@writer = Oj::StreamWriter.new(@io)
|
14
21
|
|
15
|
-
|
16
|
-
|
22
|
+
json_string = Oj.dump({ records: 1.upto(2).map{|i| { id: i, name: "record_#{i}" }} }, mode: :strict)
|
23
|
+
@test_json = StringIO.new(json_string)
|
24
|
+
|
25
|
+
@enum = Enumerator.new do |yielder|
|
26
|
+
@yielder = yielder
|
27
|
+
Oj.sc_parse(self, @test_json)
|
28
|
+
end
|
17
29
|
end
|
18
30
|
|
31
|
+
# Stream parsing methods
|
19
32
|
def hash_start
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
33
|
+
@writer.push_object
|
34
|
+
end
|
35
|
+
|
36
|
+
def hash_end
|
37
|
+
@writer.pop unless @io.eof
|
38
|
+
end
|
39
|
+
|
40
|
+
def hash_key(key)
|
41
|
+
@writer.push_key(key)
|
42
|
+
end
|
43
|
+
|
44
|
+
def hash_set(h, key, value)
|
45
|
+
@writer.push_value(value)
|
46
|
+
end
|
47
|
+
|
48
|
+
def array_start
|
49
|
+
@writer.push_array
|
24
50
|
end
|
25
51
|
|
26
|
-
|
27
|
-
|
28
|
-
|
52
|
+
def array_end
|
53
|
+
@writer.pop
|
54
|
+
end
|
55
|
+
|
56
|
+
def array_append(a, value)
|
57
|
+
yield_data
|
58
|
+
end
|
59
|
+
|
60
|
+
def add_value(value);end
|
61
|
+
|
62
|
+
def yield_data
|
63
|
+
@writer.pop_all
|
64
|
+
@yielder << @io.string
|
65
|
+
@io.reopen("")
|
66
|
+
array_start
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
#puts MyParser.new.enum.to_a
|
71
|
+
|
72
|
+
puts "------------"
|
73
|
+
|
74
|
+
MyError = Class.new(StandardError)
|
75
|
+
|
76
|
+
MyParser.new.enum.each.with_index do |r, i|
|
77
|
+
puts "========="
|
78
|
+
raise MyError.new('hello')
|
79
|
+
#raise StopIteration if i == 0
|
80
|
+
#break if i >= 4
|
29
81
|
end
|
30
82
|
|
31
|
-
|
32
|
-
parser.parse(%|{"a":{"b":{"c":{}}}}|)
|
83
|
+
#{"records":[{"id":1,"name":"record_1"},{"id":2,"name":"record_2"},{"id":3,"name":"record_3"},{"id":4,"name":"record_4"},{"id":5,"name":"record_5"},{"id":6,"name":"record_6"},{"id":7,"name":"record_7"},{"id":8,"name":"record_8"},{"id":9,"name":"record_9"},{"id":10,"name":"record_10"},{"id":11,"name":"record_11"},{"id":12,"name":"record_12"},{"id":13,"name":"record_13"},{"id":14,"name":"record_14"},{"id":15,"name":"record_15"},{"id":16,"name":"record_16"},{"id":17,"name":"record_17"},{"id":18,"name":"record_18"},{"id":19,"name":"record_19"},{"id":20,"name":"record_20"},{"id":21,"name":"record_21"},{"id":22,"name":"record_22"},{"id":23,"name":"record_23"},{"id":24,"name":"record_24"},{"id":25,"name":"record_25"}]}
|
data/test/test_scp.rb
CHANGED
@@ -350,7 +350,7 @@ class ScpTest < Minitest::Test
|
|
350
350
|
if '2.4.0' < RUBY_VERSION
|
351
351
|
handler = AllHandler.new()
|
352
352
|
json = %|{"big":-e123456789}|
|
353
|
-
assert_raises Oj::ParseError
|
353
|
+
assert_raises Exception do # Can be either Oj::ParseError or ArgumentError depending on Ruby version
|
354
354
|
Oj.sc_parse(handler, json)
|
355
355
|
end
|
356
356
|
end
|
data/test/test_various.rb
CHANGED
@@ -687,7 +687,9 @@ class Juice < Minitest::Test
|
|
687
687
|
|
688
688
|
def test_bad_bignum
|
689
689
|
if '2.4.0' < RUBY_VERSION
|
690
|
-
assert_raises
|
690
|
+
assert_raises Exception do # Can be either Oj::ParseError or ArgumentError depending on Ruby version
|
691
|
+
Oj.load(%|{ "big": -e123456789 }|)
|
692
|
+
end
|
691
693
|
end
|
692
694
|
end
|
693
695
|
|
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.7.
|
4
|
+
version: 3.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Peter Ohler
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-11-
|
11
|
+
date: 2018-11-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -79,16 +79,16 @@ extensions:
|
|
79
79
|
- ext/oj/extconf.rb
|
80
80
|
extra_rdoc_files:
|
81
81
|
- README.md
|
82
|
-
- pages/
|
82
|
+
- pages/Rails.md
|
83
|
+
- pages/JsonGem.md
|
84
|
+
- pages/Encoding.md
|
85
|
+
- pages/WAB.md
|
86
|
+
- pages/Custom.md
|
83
87
|
- pages/Advanced.md
|
84
88
|
- pages/Options.md
|
85
|
-
- pages/Custom.md
|
86
89
|
- pages/Compatibility.md
|
87
|
-
- pages/
|
90
|
+
- pages/Modes.md
|
88
91
|
- pages/Security.md
|
89
|
-
- pages/Encoding.md
|
90
|
-
- pages/JsonGem.md
|
91
|
-
- pages/Rails.md
|
92
92
|
files:
|
93
93
|
- LICENSE
|
94
94
|
- README.md
|
@@ -175,7 +175,7 @@ files:
|
|
175
175
|
- test/activesupport5/encoding_test_cases.rb
|
176
176
|
- test/activesupport5/test_helper.rb
|
177
177
|
- test/activesupport5/time_zone_test_helpers.rb
|
178
|
-
- test/
|
178
|
+
- test/bar.rb
|
179
179
|
- test/files.rb
|
180
180
|
- test/foo.rb
|
181
181
|
- test/helper.rb
|
@@ -198,7 +198,6 @@ files:
|
|
198
198
|
- test/json_gem/json_parser_test.rb
|
199
199
|
- test/json_gem/json_string_matching_test.rb
|
200
200
|
- test/json_gem/test_helper.rb
|
201
|
-
- test/mem.rb
|
202
201
|
- test/perf.rb
|
203
202
|
- test/perf_compat.rb
|
204
203
|
- test/perf_fast.rb
|
@@ -277,82 +276,81 @@ signing_key:
|
|
277
276
|
specification_version: 4
|
278
277
|
summary: A fast JSON parser and serializer.
|
279
278
|
test_files:
|
280
|
-
- test/
|
281
|
-
- test/test_hash.rb
|
282
|
-
- test/perf.rb
|
283
|
-
- test/test_object.rb
|
284
|
-
- test/test_null.rb
|
285
|
-
- test/test_compat.rb
|
286
|
-
- test/test_custom.rb
|
287
|
-
- test/perf_scp.rb
|
279
|
+
- test/foo.rb
|
288
280
|
- test/test_integer_range.rb
|
289
|
-
- test/
|
290
|
-
- test/
|
291
|
-
- test/
|
281
|
+
- test/test_strict.rb
|
282
|
+
- test/perf_strict.rb
|
283
|
+
- test/tests.rb
|
284
|
+
- test/perf_saj.rb
|
285
|
+
- test/test_compat.rb
|
286
|
+
- test/helper.rb
|
287
|
+
- test/perf_file.rb
|
288
|
+
- test/test_scp.rb
|
289
|
+
- test/perf_compat.rb
|
290
|
+
- test/json_gem/json_common_interface_test.rb
|
292
291
|
- test/json_gem/json_addition_test.rb
|
293
|
-
- test/json_gem/
|
292
|
+
- test/json_gem/json_fixtures_test.rb
|
293
|
+
- test/json_gem/json_ext_parser_test.rb
|
294
|
+
- test/json_gem/json_string_matching_test.rb
|
295
|
+
- test/json_gem/json_generic_object_test.rb
|
294
296
|
- test/json_gem/json_generator_test.rb
|
295
|
-
- test/json_gem/
|
297
|
+
- test/json_gem/test_helper.rb
|
296
298
|
- test/json_gem/json_encoding_test.rb
|
297
|
-
- test/json_gem/
|
298
|
-
- test/
|
299
|
-
- test/
|
300
|
-
- test/
|
301
|
-
- test/
|
302
|
-
- test/
|
299
|
+
- test/json_gem/json_parser_test.rb
|
300
|
+
- test/perf_wab.rb
|
301
|
+
- test/test_file.rb
|
302
|
+
- test/test_object.rb
|
303
|
+
- test/sample.rb
|
304
|
+
- test/perf_object.rb
|
305
|
+
- test/test_hash.rb
|
306
|
+
- test/test_custom.rb
|
307
|
+
- test/bar.rb
|
308
|
+
- test/activesupport4/encoding_test.rb
|
303
309
|
- test/activesupport4/test_helper.rb
|
304
310
|
- test/activesupport4/decoding_test.rb
|
305
|
-
- test/
|
306
|
-
- test/activerecord/result_test.rb
|
307
|
-
- test/_test_active.rb
|
308
|
-
- test/test_file.rb
|
311
|
+
- test/sample_json.rb
|
309
312
|
- test/activesupport5/encoding_test_cases.rb
|
313
|
+
- test/activesupport5/encoding_test.rb
|
310
314
|
- test/activesupport5/time_zone_test_helpers.rb
|
311
315
|
- test/activesupport5/test_helper.rb
|
312
316
|
- test/activesupport5/decoding_test.rb
|
313
|
-
- test/activesupport5/encoding_test.rb
|
314
|
-
- test/tests.rb
|
315
|
-
- test/_test_active_mimic.rb
|
316
|
-
- test/perf_object.rb
|
317
|
-
- test/test_strict.rb
|
318
|
-
- test/test_scp.rb
|
319
|
-
- test/perf_wab.rb
|
320
317
|
- test/test_saj.rb
|
321
|
-
- test/
|
322
|
-
- test/
|
323
|
-
- test/
|
324
|
-
- test/
|
325
|
-
- test/
|
326
|
-
- test/isolated/test_mimic_rails_after.rb
|
327
|
-
- test/isolated/test_mimic_after.rb
|
328
|
-
- test/isolated/test_mimic_rails_before.rb
|
329
|
-
- test/isolated/test_mimic_as_json.rb
|
330
|
-
- test/isolated/test_mimic_redefine.rb
|
331
|
-
- test/isolated/shared.rb
|
332
|
-
- test/isolated/test_mimic_before.rb
|
333
|
-
- test/sample_json.rb
|
334
|
-
- test/test_debian.rb
|
335
|
-
- test/perf_fast.rb
|
336
|
-
- test/test_writer.rb
|
318
|
+
- test/perf_scp.rb
|
319
|
+
- test/test_wab.rb
|
320
|
+
- test/test_null.rb
|
321
|
+
- test/_test_active.rb
|
322
|
+
- test/_test_mimic_rails.rb
|
337
323
|
- test/test_fast.rb
|
338
|
-
- test/
|
324
|
+
- test/perf_fast.rb
|
339
325
|
- test/sample/change.rb
|
340
|
-
- test/sample/dir.rb
|
341
326
|
- test/sample/text.rb
|
342
|
-
- test/sample/layer.rb
|
343
|
-
- test/sample/rect.rb
|
344
|
-
- test/sample/group.rb
|
345
|
-
- test/sample/oval.rb
|
346
327
|
- test/sample/doc.rb
|
347
|
-
- test/sample/hasprops.rb
|
348
328
|
- test/sample/shape.rb
|
329
|
+
- test/sample/layer.rb
|
330
|
+
- test/sample/group.rb
|
349
331
|
- test/sample/file.rb
|
350
|
-
- test/
|
351
|
-
- test/
|
352
|
-
- test/
|
353
|
-
- test/
|
332
|
+
- test/sample/rect.rb
|
333
|
+
- test/sample/hasprops.rb
|
334
|
+
- test/sample/line.rb
|
335
|
+
- test/sample/dir.rb
|
336
|
+
- test/sample/oval.rb
|
354
337
|
- test/tests_mimic.rb
|
355
|
-
- test/perf_strict.rb
|
356
|
-
- test/test_various.rb
|
357
|
-
- test/_test_mimic_rails.rb
|
358
338
|
- test/perf_simple.rb
|
339
|
+
- test/activerecord/result_test.rb
|
340
|
+
- test/_test_active_mimic.rb
|
341
|
+
- test/tests_mimic_addition.rb
|
342
|
+
- test/test_writer.rb
|
343
|
+
- test/perf.rb
|
344
|
+
- test/isolated/test_mimic_define.rb
|
345
|
+
- test/isolated/test_mimic_after.rb
|
346
|
+
- test/isolated/test_mimic_rails_after.rb
|
347
|
+
- test/isolated/test_mimic_before.rb
|
348
|
+
- test/isolated/test_mimic_rails_before.rb
|
349
|
+
- test/isolated/test_mimic_redefine.rb
|
350
|
+
- test/isolated/shared.rb
|
351
|
+
- test/isolated/test_mimic_alone.rb
|
352
|
+
- test/isolated/test_mimic_as_json.rb
|
353
|
+
- test/test_debian.rb
|
354
|
+
- test/test_gc.rb
|
355
|
+
- test/files.rb
|
356
|
+
- test/test_various.rb
|
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
|