oj 3.11.4 → 3.11.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/oj/mimic_json.c +7 -1
- data/ext/oj/oj.c +2 -1
- data/lib/oj/version.rb +1 -1
- data/test/test_generate.rb +21 -0
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 964a9272c141179cf6f61317e89bc8dab43184b0d143355dc2212b89f123ccad
|
4
|
+
data.tar.gz: 53a3b3cd773a87953cec71a649f491682b022c13d56ebcc4eb5653bc9cbb560e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 947dad8a5cfc4d5adb3efbd40218439c984ae6084ef304f6b3012e26e047438a03b6f149b7c224982fc8fd0a699b56fa0e6b9a174e8b00d6567dd911f601f227
|
7
|
+
data.tar.gz: 536b05addb483b631883ccfb9269c6cd93b3e988ea9845021be3e2383a708974ff4e63a9d64a1a76bd8a9934969c42aa16495eccd75e88b7cf4704f619e7b693
|
data/ext/oj/mimic_json.c
CHANGED
@@ -19,7 +19,7 @@ VALUE oj_object_nl_sym;
|
|
19
19
|
VALUE oj_space_before_sym;
|
20
20
|
VALUE oj_space_sym;
|
21
21
|
|
22
|
-
static VALUE state_class;
|
22
|
+
static VALUE state_class = Qundef;
|
23
23
|
|
24
24
|
// mimic JSON documentation
|
25
25
|
|
@@ -389,6 +389,9 @@ static VALUE mimic_generate_core(int argc, VALUE *argv, Options copts) {
|
|
389
389
|
} else {
|
390
390
|
VALUE active_hack[1];
|
391
391
|
|
392
|
+
if (Qundef == state_class) {
|
393
|
+
oj_define_mimic_json(0, NULL, Qnil);
|
394
|
+
}
|
392
395
|
active_hack[0] = rb_funcall(state_class, oj_new_id, 0);
|
393
396
|
oj_dump_obj_to_json_using_params(*argv, copts, &out, 1, active_hack);
|
394
397
|
}
|
@@ -476,6 +479,9 @@ oj_mimic_pretty_generate(int argc, VALUE *argv, VALUE self) {
|
|
476
479
|
if (Qfalse == rb_funcall(h, oj_has_key_id, 1, oj_array_nl_sym)) {
|
477
480
|
rb_hash_aset(h, oj_array_nl_sym, rb_str_new2("\n"));
|
478
481
|
}
|
482
|
+
if (Qundef == state_class) {
|
483
|
+
oj_define_mimic_json(0, NULL, Qnil);
|
484
|
+
}
|
479
485
|
rargs[1] = rb_funcall(state_class, oj_new_id, 1, h);
|
480
486
|
|
481
487
|
copts.str_rx.head = NULL;
|
data/ext/oj/oj.c
CHANGED
@@ -1610,7 +1610,8 @@ extern VALUE oj_define_mimic_json(int argc, VALUE *argv, VALUE self);
|
|
1610
1610
|
*
|
1611
1611
|
* Encode obj as a JSON String. The obj argument must be a Hash, Array, or
|
1612
1612
|
* respond to to_h or to_json. Options other than those listed such as
|
1613
|
-
* +:allow_nan+ or +:max_nesting+ are ignored.
|
1613
|
+
* +:allow_nan+ or +:max_nesting+ are ignored. Calling this method will call
|
1614
|
+
* Oj.mimic_JSON if it is not already called.
|
1614
1615
|
*
|
1615
1616
|
* - *obj* [_Object__|_Hash_|_Array_] object to convert to a JSON String
|
1616
1617
|
* - *opts* [_Hash_] options
|
data/lib/oj/version.rb
CHANGED
@@ -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 'minitest'
|
11
|
+
require 'minitest/autorun'
|
12
|
+
require 'oj'
|
13
|
+
|
14
|
+
class Generator < Minitest::Test
|
15
|
+
|
16
|
+
def test_before
|
17
|
+
json = Oj.generate({})
|
18
|
+
assert_equal("{}", json)
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
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.5
|
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-04-
|
11
|
+
date: 2021-04-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -240,6 +240,7 @@ files:
|
|
240
240
|
- test/test_fast.rb
|
241
241
|
- test/test_file.rb
|
242
242
|
- test/test_gc.rb
|
243
|
+
- test/test_generate.rb
|
243
244
|
- test/test_hash.rb
|
244
245
|
- test/test_integer_range.rb
|
245
246
|
- test/test_null.rb
|
@@ -364,6 +365,7 @@ test_files:
|
|
364
365
|
- test/test_fast.rb
|
365
366
|
- test/test_file.rb
|
366
367
|
- test/test_gc.rb
|
368
|
+
- test/test_generate.rb
|
367
369
|
- test/test_hash.rb
|
368
370
|
- test/test_integer_range.rb
|
369
371
|
- test/test_null.rb
|