oj 3.7.10 → 3.7.11

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 19c25560b508ae039d9d517cb5eacb44b658e1359e11e95317b51ff94581ea6d
4
- data.tar.gz: 2ea2c2a50e8cf6d14a7c19427def90fefc460fbb626226c6299a91c8890fbeaf
3
+ metadata.gz: 5d48227161f707ac83a49469686bfcdbe44376055ebdcd1a449f5e62a1089256
4
+ data.tar.gz: ef7636a3fecfa42d00246ebedab1784a2ee9c935e863694dba38aca471b477bc
5
5
  SHA512:
6
- metadata.gz: 91ee09165357ad4955030f2d395f61578375c70672245483831d1c291fe76b50c1166c4d6d75435d4961a6aac394d03069320cb8e15e6b352cf6c634d5ab0b5d
7
- data.tar.gz: ea098163b5b4297777de3dcdfc1468673114ba264fd7f2733620ffe14d3ef784384ac0b8fa8c0482f5303b5c4f47164943462266af91d1662ed4eeee5d893656
6
+ metadata.gz: c4dc96bbdff56dd250c03eca2576a502167470c077b8852eae1698636b8dad3f9c188d4a4f755766425de7f21ab4e363938352f80a3be76da36f6bfad3e57a42
7
+ data.tar.gz: 77e579b56103860a3364c0e33a91fd33e5fd55e15a2385b1a9993b6fb6c11f1ec31d3b7b4cd968e08b135a772d2d786f86503a113cb0c847049b332a4397b0a5
@@ -8,7 +8,7 @@
8
8
  #include "dump.h"
9
9
  #include "parse.h"
10
10
 
11
- static VALUE symbolize_names_sym;
11
+ static VALUE symbolize_names_sym = Qundef;
12
12
 
13
13
  extern const char oj_json_class[];
14
14
 
@@ -26,30 +26,30 @@ static VALUE state_class;
26
26
  // mimic JSON documentation
27
27
 
28
28
  /* Document-module: JSON::Ext
29
- *
29
+ *
30
30
  * The Ext module is a placeholder in the mimic JSON module used for
31
31
  * compatibility only.
32
32
  */
33
33
  /* Document-class: JSON::Ext::Parser
34
- *
34
+ *
35
35
  * The JSON::Ext::Parser is a placeholder in the mimic JSON module used for
36
36
  * compatibility only.
37
37
  */
38
38
  /* Document-class: JSON::Ext::Generator
39
- *
39
+ *
40
40
  * The JSON::Ext::Generator is a placeholder in the mimic JSON module used for
41
41
  * compatibility only.
42
42
  */
43
43
 
44
44
  /* Document-method: parser=
45
45
  * call-seq: parser=(parser)
46
- *
46
+ *
47
47
  * Does nothing other than provide compatibility.
48
48
  * - *parser* [_Object_] ignored
49
49
  */
50
50
  /* Document-method: generator=
51
51
  * call-seq: generator=(generator)
52
- *
52
+ *
53
53
  * Does nothing other than provide compatibility.
54
54
  * - *generator* [_Object_] ignored
55
55
  */
@@ -184,9 +184,9 @@ mimic_limit_arg(VALUE a) {
184
184
 
185
185
  /* Document-method: dump
186
186
  * call-seq: dump(obj, anIO=nil, limit=nil)
187
- *
187
+ *
188
188
  * Encodes an object as a JSON String.
189
- *
189
+ *
190
190
  * - *obj* [_Object_] object to convert to encode as JSON
191
191
  * - *anIO* [_IO_] an IO that allows writing
192
192
  * - *limit* [_Fixnum_] ignored
@@ -218,7 +218,7 @@ mimic_dump(int argc, VALUE *argv, VALUE self) {
218
218
  out.omit_nil = copts.dump_opts.omit_nil;
219
219
  if (2 <= argc) {
220
220
  int limit;
221
-
221
+
222
222
  // The json gem take a more liberal approach to optional
223
223
  // arguments. Expected are (obj, anIO=nil, limit=nil) yet the io
224
224
  // argument can be left off completely and the 2nd argument is then
@@ -285,11 +285,11 @@ mimic_walk(VALUE key, VALUE obj, VALUE proc) {
285
285
 
286
286
  /* Document-method: restore
287
287
  * call-seq: restore(source, proc=nil)
288
- *
288
+ *
289
289
  * Loads a Ruby Object from a JSON source that can be either a String or an
290
290
  * IO. If Proc is given or a block is providedit is called with each nested
291
291
  * element of the loaded Object.
292
- *
292
+ *
293
293
  * - *source* [_String_|IO] JSON source
294
294
  * - *proc* [_Proc_] to yield to on each element or nil
295
295
  *
@@ -298,11 +298,11 @@ mimic_walk(VALUE key, VALUE obj, VALUE proc) {
298
298
 
299
299
  /* Document-method: load
300
300
  * call-seq: load(source, proc=nil)
301
- *
301
+ *
302
302
  * Loads a Ruby Object from a JSON source that can be either a String or an
303
303
  * IO. If Proc is given or a block is providedit is called with each nested
304
304
  * element of the loaded Object.
305
- *
305
+ *
306
306
  * - *source* [_String_|IO] JSON source
307
307
  * - *proc* [_Proc_] to yield to on each element or nil
308
308
  *
@@ -330,10 +330,10 @@ mimic_load(int argc, VALUE *argv, VALUE self) {
330
330
 
331
331
  /* Document-method: []
332
332
  * call-seq: [](obj, opts={})
333
- *
333
+ *
334
334
  * If the obj argument is a String then it is assumed to be a JSON String and
335
335
  * parsed otherwise the obj is encoded as a JSON String.
336
- *
336
+ *
337
337
  * - *obj* [_String_|Hash|Array] object to convert
338
338
  * - *opts* [_Hash_] same options as either generate or parse
339
339
  *
@@ -396,11 +396,11 @@ mimic_generate_core(int argc, VALUE *argv, Options copts) {
396
396
 
397
397
  /* Document-method: generate
398
398
  * call-seq: generate(obj, opts=nil)
399
- *
399
+ *
400
400
  * Encode obj as a JSON String. The obj argument must be a Hash, Array, or
401
401
  * respond to to_h or to_json. Options other than those listed such as
402
402
  * +:allow_nan+ or +:max_nesting+ are ignored.
403
- *
403
+ *
404
404
  * - *obj* [_Object_|Hash|Array] object to convert to a JSON String
405
405
  * - *opts* [_Hash_] options
406
406
  * - - *:indent* [_String_] String to use for indentation.
@@ -461,7 +461,7 @@ oj_mimic_pretty_generate(int argc, VALUE *argv, VALUE self) {
461
461
  rb_hash_aset(h, oj_array_nl_sym, rb_str_new2("\n"));
462
462
  }
463
463
  rargs[1] = rb_funcall(state_class, oj_new_id, 1, h);
464
-
464
+
465
465
  copts.str_rx.head = NULL;
466
466
  copts.str_rx.tail = NULL;
467
467
  strcpy(copts.dump_opts.indent_str, " ");
@@ -510,6 +510,9 @@ mimic_parse_core(int argc, VALUE *argv, VALUE self, bool bang) {
510
510
  if (T_HASH != rb_type(ropts)) {
511
511
  rb_raise(rb_eArgError, "options must be a hash.");
512
512
  }
513
+ if (Qundef == symbolize_names_sym) {
514
+ symbolize_names_sym = ID2SYM(rb_intern("symbolize_names")); rb_gc_register_address(&symbolize_names_sym);
515
+ }
513
516
  if (Qnil != (v = rb_hash_lookup(ropts, symbolize_names_sym))) {
514
517
  pi.options.sym_key = (Qtrue == v) ? Yes : No;
515
518
  }
@@ -602,9 +605,9 @@ mimic_parse_bang(int argc, VALUE *argv, VALUE self) {
602
605
 
603
606
  /* Document-method: recurse_proc
604
607
  * call-seq: recurse_proc(obj, &proc)
605
- *
608
+ *
606
609
  * Yields to the proc for every element in the obj recursively.
607
- *
610
+ *
608
611
  * - *obj* [_Hash_|Array] object to walk
609
612
  * - *proc* [_Proc_] to yield to on each element
610
613
  */
@@ -834,7 +837,7 @@ oj_define_mimic_json(int argc, VALUE *argv, VALUE self) {
834
837
  VALUE dummy;
835
838
  VALUE verbose;
836
839
  VALUE json;
837
-
840
+
838
841
  // Either set the paths to indicate JSON has been loaded or replaces the
839
842
  // methods if it has been loaded.
840
843
  if (rb_const_defined_at(rb_cObject, rb_intern("JSON"))) {
@@ -1,5 +1,5 @@
1
1
 
2
2
  module Oj
3
3
  # Current version of the module.
4
- VERSION = '3.7.10'
4
+ VERSION = '3.7.11'
5
5
  end
@@ -0,0 +1,25 @@
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
+
12
+ #Oj.load_file(ARGV[0], mode: :strict) { |obj|
13
+ # puts Oj.dump(obj, indent: 2)
14
+ #}
15
+
16
+ data = open('invalid_unicode.data').read
17
+
18
+ puts data
19
+
20
+ puts Oj.dump(data)
21
+
22
+ Oj.mimic_JSON
23
+ puts Oj.dump(data, escape_mode: :json)
24
+
25
+ puts Oj.default_options
@@ -0,0 +1,21 @@
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 'active_support'
12
+ require 'active_support/json'
13
+ #require 'tracer'
14
+
15
+ Oj::Rails.set_encoder()
16
+ Oj::Rails.set_decoder()
17
+ Oj::Rails.optimize()
18
+
19
+ #Oj::mimic_JSON
20
+
21
+ puts JSON.parse('{"a":1}', symbolize_names: true)
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ #require 'json'
4
+
5
+ $: << File.dirname(__FILE__)
6
+ require 'helper'
7
+ require 'oj'
8
+
9
+ Oj.mimic_JSON
10
+ puts "\u3074"
11
+
12
+ puts JSON.dump(["\u3074"])
13
+ puts JSON.generate(["\u3074"])
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.10
4
+ version: 3.7.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Ohler
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-03-14 00:00:00.000000000 Z
11
+ date: 2019-03-20 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/Rails.md
83
+ - pages/JsonGem.md
84
+ - pages/Encoding.md
85
+ - pages/WAB.md
86
+ - pages/Custom.md
82
87
  - pages/Advanced.md
88
+ - pages/Options.md
83
89
  - pages/Compatibility.md
84
- - pages/Custom.md
85
- - pages/Encoding.md
86
- - pages/JsonGem.md
87
90
  - pages/Modes.md
88
- - pages/Options.md
89
- - pages/Rails.md
90
91
  - pages/Security.md
91
- - pages/WAB.md
92
92
  files:
93
93
  - LICENSE
94
94
  - README.md
@@ -177,9 +177,9 @@ files:
177
177
  - test/activesupport5/encoding_test_cases.rb
178
178
  - test/activesupport5/test_helper.rb
179
179
  - test/activesupport5/time_zone_test_helpers.rb
180
- - test/bug.rb
181
- - test/crash.rb
180
+ - test/bar.rb
182
181
  - test/files.rb
182
+ - test/foo.rb
183
183
  - test/helper.rb
184
184
  - test/isolated/shared.rb
185
185
  - test/isolated/test_mimic_after.rb
@@ -243,6 +243,7 @@ files:
243
243
  - test/tests.rb
244
244
  - test/tests_mimic.rb
245
245
  - test/tests_mimic_addition.rb
246
+ - test/zoo.rb
246
247
  homepage: http://www.ohler.com/oj
247
248
  licenses:
248
249
  - MIT
@@ -277,81 +278,82 @@ signing_key:
277
278
  specification_version: 4
278
279
  summary: A fast JSON parser and serializer.
279
280
  test_files:
280
- - test/_test_active.rb
281
- - test/_test_active_mimic.rb
282
- - test/_test_mimic_rails.rb
283
- - test/activerecord/result_test.rb
284
- - test/activesupport4/decoding_test.rb
285
- - test/activesupport4/encoding_test.rb
286
- - test/activesupport4/test_helper.rb
287
- - test/activesupport5/decoding_test.rb
288
- - test/activesupport5/encoding_test.rb
289
- - test/activesupport5/encoding_test_cases.rb
290
- - test/activesupport5/test_helper.rb
291
- - test/activesupport5/time_zone_test_helpers.rb
292
- - test/bug.rb
293
- - test/crash.rb
294
- - test/files.rb
281
+ - test/foo.rb
282
+ - test/test_integer_range.rb
283
+ - test/test_strict.rb
284
+ - test/perf_strict.rb
285
+ - test/tests.rb
286
+ - test/perf_saj.rb
287
+ - test/test_compat.rb
295
288
  - test/helper.rb
296
- - test/isolated/shared.rb
297
- - test/isolated/test_mimic_after.rb
298
- - test/isolated/test_mimic_alone.rb
299
- - test/isolated/test_mimic_as_json.rb
300
- - test/isolated/test_mimic_before.rb
301
- - test/isolated/test_mimic_define.rb
302
- - test/isolated/test_mimic_rails_after.rb
303
- - test/isolated/test_mimic_rails_before.rb
304
- - test/isolated/test_mimic_redefine.rb
305
- - test/json_gem/json_addition_test.rb
289
+ - test/perf_file.rb
290
+ - test/test_scp.rb
291
+ - test/perf_compat.rb
306
292
  - test/json_gem/json_common_interface_test.rb
307
- - test/json_gem/json_encoding_test.rb
308
- - test/json_gem/json_ext_parser_test.rb
293
+ - test/json_gem/json_addition_test.rb
309
294
  - test/json_gem/json_fixtures_test.rb
310
- - test/json_gem/json_generator_test.rb
311
- - test/json_gem/json_generic_object_test.rb
312
- - test/json_gem/json_parser_test.rb
295
+ - test/json_gem/json_ext_parser_test.rb
313
296
  - test/json_gem/json_string_matching_test.rb
297
+ - test/json_gem/json_generic_object_test.rb
298
+ - test/json_gem/json_generator_test.rb
314
299
  - test/json_gem/test_helper.rb
315
- - test/perf.rb
316
- - test/perf_compat.rb
317
- - test/perf_fast.rb
318
- - test/perf_file.rb
300
+ - test/json_gem/json_encoding_test.rb
301
+ - test/json_gem/json_parser_test.rb
302
+ - test/perf_wab.rb
303
+ - test/test_file.rb
304
+ - test/test_object.rb
305
+ - test/sample.rb
319
306
  - test/perf_object.rb
320
- - test/perf_saj.rb
307
+ - test/test_hash.rb
308
+ - test/test_custom.rb
309
+ - test/bar.rb
310
+ - test/activesupport4/encoding_test.rb
311
+ - test/activesupport4/test_helper.rb
312
+ - test/activesupport4/decoding_test.rb
313
+ - test/sample_json.rb
314
+ - test/activesupport5/encoding_test_cases.rb
315
+ - test/activesupport5/encoding_test.rb
316
+ - test/activesupport5/time_zone_test_helpers.rb
317
+ - test/activesupport5/test_helper.rb
318
+ - test/activesupport5/decoding_test.rb
319
+ - test/test_saj.rb
321
320
  - test/perf_scp.rb
322
- - test/perf_simple.rb
323
- - test/perf_strict.rb
324
- - test/perf_wab.rb
321
+ - test/test_wab.rb
322
+ - test/test_null.rb
323
+ - test/_test_active.rb
324
+ - test/_test_mimic_rails.rb
325
+ - test/test_fast.rb
326
+ - test/perf_fast.rb
325
327
  - test/sample/change.rb
326
- - test/sample/dir.rb
328
+ - test/sample/text.rb
327
329
  - test/sample/doc.rb
328
- - test/sample/file.rb
330
+ - test/sample/shape.rb
331
+ - test/sample/layer.rb
329
332
  - test/sample/group.rb
333
+ - test/sample/file.rb
334
+ - test/sample/rect.rb
330
335
  - test/sample/hasprops.rb
331
- - test/sample/layer.rb
332
336
  - test/sample/line.rb
337
+ - test/sample/dir.rb
333
338
  - test/sample/oval.rb
334
- - test/sample/rect.rb
335
- - test/sample/shape.rb
336
- - test/sample/text.rb
337
- - test/sample.rb
338
- - test/sample_json.rb
339
- - test/test_compat.rb
340
- - test/test_custom.rb
339
+ - test/tests_mimic.rb
340
+ - test/perf_simple.rb
341
+ - test/zoo.rb
342
+ - test/activerecord/result_test.rb
343
+ - test/_test_active_mimic.rb
344
+ - test/tests_mimic_addition.rb
345
+ - test/test_writer.rb
346
+ - test/perf.rb
347
+ - test/isolated/test_mimic_define.rb
348
+ - test/isolated/test_mimic_after.rb
349
+ - test/isolated/test_mimic_rails_after.rb
350
+ - test/isolated/test_mimic_before.rb
351
+ - test/isolated/test_mimic_rails_before.rb
352
+ - test/isolated/test_mimic_redefine.rb
353
+ - test/isolated/shared.rb
354
+ - test/isolated/test_mimic_alone.rb
355
+ - test/isolated/test_mimic_as_json.rb
341
356
  - test/test_debian.rb
342
- - test/test_fast.rb
343
- - test/test_file.rb
344
357
  - test/test_gc.rb
345
- - test/test_hash.rb
346
- - test/test_integer_range.rb
347
- - test/test_null.rb
348
- - test/test_object.rb
349
- - test/test_saj.rb
350
- - test/test_scp.rb
351
- - test/test_strict.rb
358
+ - test/files.rb
352
359
  - test/test_various.rb
353
- - test/test_wab.rb
354
- - test/test_writer.rb
355
- - test/tests.rb
356
- - test/tests_mimic.rb
357
- - test/tests_mimic_addition.rb
@@ -1,25 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: UTF-8
3
-
4
- %w(lib ext test).each do |dir|
5
- $LOAD_PATH.unshift File.expand_path("../../#{dir}", __FILE__)
6
- end
7
-
8
- require 'rails'
9
- require 'active_support'
10
- require 'active_support/json'
11
- require 'oj'
12
-
13
- x = {"a": BigDecimal("1.1"), "t": Time.now}
14
-
15
- #ActiveSupport.encode_big_decimal_as_string = false
16
-
17
- Oj.optimize_rails
18
-
19
- puts "to_json #{x.to_json}"
20
-
21
- Oj.default_options = { bigdecimal_as_decimal: true}
22
- #puts Oj.default_options
23
-
24
- puts "to_json #{x.to_json}"
25
-
@@ -1,22 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # encoding: UTF-8
3
-
4
- #$VERBOSE = true
5
-
6
- %w(lib ext test).each do |dir|
7
- $LOAD_PATH.unshift File.expand_path("../../#{dir}", __FILE__)
8
- end
9
-
10
- require 'active_support'
11
- require 'active_support/core_ext'
12
- require 'active_support/json'
13
- require 'oj'
14
-
15
- Oj.optimize_rails
16
-
17
- 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}]}
18
-
19
- 100000.times {
20
- JSON.pretty_generate(h)
21
- }
22
- #puts JSON.generate(h)