json 1.2.2 → 1.2.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of json might be problematic. Click here for more details.
- data/CHANGES +3 -0
- data/VERSION +1 -1
- data/ext/json/ext/generator/generator.c +20 -1
- data/lib/json/pure/generator.rb +5 -0
- data/lib/json/version.rb +1 -1
- data/tests/test_json_generate.rb +4 -2
- metadata +2 -2
data/CHANGES
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.2.
|
1
|
+
1.2.3
|
@@ -41,7 +41,8 @@ static VALUE mJSON, mExt, mGenerator, cState, mGeneratorMethods, mObject,
|
|
41
41
|
|
42
42
|
static ID i_to_s, i_to_json, i_new, i_indent, i_space, i_space_before,
|
43
43
|
i_object_nl, i_array_nl, i_check_circular, i_max_nesting,
|
44
|
-
i_allow_nan, i_pack, i_unpack, i_create_id, i_extend, i_key_p
|
44
|
+
i_allow_nan, i_pack, i_unpack, i_create_id, i_extend, i_key_p,
|
45
|
+
i_aref, i_send, i_respond_to_p;
|
45
46
|
|
46
47
|
typedef struct JSON_Generator_StateStruct {
|
47
48
|
VALUE indent;
|
@@ -584,6 +585,20 @@ static VALUE cState_to_h(VALUE self)
|
|
584
585
|
return result;
|
585
586
|
}
|
586
587
|
|
588
|
+
/*
|
589
|
+
* call-seq: [](name)
|
590
|
+
*
|
591
|
+
* Return the value returned by method +name+.
|
592
|
+
*/
|
593
|
+
static VALUE cState_aref(VALUE self, VALUE name)
|
594
|
+
{
|
595
|
+
GET_STATE(self);
|
596
|
+
if (RTEST(rb_funcall(self, i_respond_to_p, 1, name))) {
|
597
|
+
return rb_funcall(self, i_send, 1, name);
|
598
|
+
} else {
|
599
|
+
return Qnil;
|
600
|
+
}
|
601
|
+
}
|
587
602
|
|
588
603
|
/*
|
589
604
|
* call-seq: new(opts = {})
|
@@ -884,6 +899,7 @@ void Init_generator()
|
|
884
899
|
rb_define_method(cState, "forget", cState_forget, 1);
|
885
900
|
rb_define_method(cState, "configure", cState_configure, 1);
|
886
901
|
rb_define_method(cState, "to_h", cState_to_h, 0);
|
902
|
+
rb_define_method(cState, "[]", cState_aref, 1);
|
887
903
|
|
888
904
|
mGeneratorMethods = rb_define_module_under(mGenerator, "GeneratorMethods");
|
889
905
|
mObject = rb_define_module_under(mGeneratorMethods, "Object");
|
@@ -926,6 +942,9 @@ void Init_generator()
|
|
926
942
|
i_create_id = rb_intern("create_id");
|
927
943
|
i_extend = rb_intern("extend");
|
928
944
|
i_key_p = rb_intern("key?");
|
945
|
+
i_aref = rb_intern("[]");
|
946
|
+
i_send = rb_intern("__send__");
|
947
|
+
i_respond_to_p = rb_intern("respond_to?");
|
929
948
|
#ifdef HAVE_RUBY_ENCODING_H
|
930
949
|
mEncoding_UTF_8 = rb_funcall(rb_path2class("Encoding"), rb_intern("find"), 1, rb_str_new2("utf-8"));
|
931
950
|
i_encoding = rb_intern("encoding");
|
data/lib/json/pure/generator.rb
CHANGED
data/lib/json/version.rb
CHANGED
data/tests/test_json_generate.rb
CHANGED
@@ -88,13 +88,15 @@ EOT
|
|
88
88
|
json = generate({1=>2}, nil)
|
89
89
|
assert_equal('{"1":2}', json)
|
90
90
|
s = JSON.state.new(:check_circular => true)
|
91
|
-
|
91
|
+
assert s.check_circular?
|
92
|
+
assert s[:check_circular?]
|
92
93
|
h = { 1=>2 }
|
93
94
|
h[3] = h
|
94
95
|
assert_raises(JSON::CircularDatastructure) { generate(h) }
|
95
96
|
assert_raises(JSON::CircularDatastructure) { generate(h, s) }
|
96
97
|
s = JSON.state.new(:check_circular => true)
|
97
|
-
|
98
|
+
assert s.check_circular?
|
99
|
+
assert s[:check_circular?]
|
98
100
|
a = [ 1, 2 ]
|
99
101
|
a << a
|
100
102
|
assert_raises(JSON::CircularDatastructure) { generate(a, s) }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: json
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Florian Frank
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2010-
|
12
|
+
date: 2010-03-11 00:00:00 +01:00
|
13
13
|
default_executable: edit_json.rb
|
14
14
|
dependencies: []
|
15
15
|
|