json 2.1.0 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.travis.yml +9 -4
- data/CHANGES.md +3 -0
- data/Gemfile +0 -2
- data/LICENSE +56 -0
- data/README.md +38 -21
- data/Rakefile +10 -5
- data/VERSION +1 -1
- data/ext/json/ext/generator/generator.c +96 -40
- data/ext/json/ext/parser/parser.c +106 -79
- data/ext/json/ext/parser/parser.rl +33 -6
- data/java/src/json/ext/Generator.java +33 -10
- data/java/src/json/ext/Parser.java +3 -3
- data/java/src/json/ext/Parser.rl +1 -1
- data/json-java.gemspec +1 -2
- data/json.gemspec +0 -0
- data/json_pure.gemspec +5 -5
- data/lib/json/add/bigdecimal.rb +2 -2
- data/lib/json/add/complex.rb +2 -2
- data/lib/json/add/ostruct.rb +1 -1
- data/lib/json/add/rational.rb +2 -2
- data/lib/json/add/regexp.rb +2 -2
- data/lib/json/add/set.rb +29 -0
- data/lib/json/common.rb +2 -2
- data/lib/json/pure/generator.rb +2 -1
- data/lib/json/pure/parser.rb +9 -1
- data/lib/json/version.rb +1 -1
- data/tests/json_addition_test.rb +10 -0
- data/tests/json_common_interface_test.rb +4 -4
- data/tests/json_generator_test.rb +44 -0
- data/tests/json_parser_test.rb +15 -14
- data/tests/test_helper.rb +0 -4
- metadata +5 -7
- data/data/example.json +0 -1
- data/data/index.html +0 -38
- data/data/prototype.js +0 -4184
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ca534a7e54763534530fcc4d010c6ff3e45ae08959e64d7a54e2ed6b1c4d6cf4
|
4
|
+
data.tar.gz: 5ed1902c0706bb321b4f4833203c4b6ae3cd47c4303bca04977442965ef9cbe6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 70cefe1d1604c66bff786a1f530acd9fab15670957b84a0efc91d450e130e0b48da6ff0d8858549413fe6beb956b3d19d313f178cbe8f5123ec32ab701635bf9
|
7
|
+
data.tar.gz: d0b3f6d760d2100b47e4160f372344d057f60ddd7c58e3bc2dceb35b690cbd14e6af75a3028d121099f1586ed134876c16bdf7ad58e68c7295e5c0cc20f52538
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -4,16 +4,21 @@ language: ruby
|
|
4
4
|
|
5
5
|
# Specify which ruby versions you wish to run your tests on, each version will be used
|
6
6
|
rvm:
|
7
|
-
- 1.9.3
|
8
7
|
- 2.0.0
|
9
8
|
- 2.1
|
10
9
|
- 2.2
|
11
|
-
- 2.3
|
12
|
-
- 2.4
|
13
|
-
-
|
10
|
+
- 2.3
|
11
|
+
- 2.4
|
12
|
+
- 2.5
|
13
|
+
- 2.6
|
14
|
+
- 2.7.0-preview3
|
14
15
|
- ruby-head
|
16
|
+
- jruby
|
17
|
+
- jruby-9.2.7.0
|
15
18
|
matrix:
|
16
19
|
allow_failures:
|
17
20
|
- rvm: ruby-head
|
21
|
+
- rvm: jruby
|
22
|
+
- rvm: jruby-9.2.7.0
|
18
23
|
script: "bundle exec rake"
|
19
24
|
sudo: false
|
data/CHANGES.md
CHANGED
data/Gemfile
CHANGED
data/LICENSE
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
Ruby is copyrighted free software by Yukihiro Matsumoto <matz@netlab.jp>.
|
2
|
+
You can redistribute it and/or modify it under either the terms of the
|
3
|
+
2-clause BSDL (see the file BSDL), or the conditions below:
|
4
|
+
|
5
|
+
1. You may make and give away verbatim copies of the source form of the
|
6
|
+
software without restriction, provided that you duplicate all of the
|
7
|
+
original copyright notices and associated disclaimers.
|
8
|
+
|
9
|
+
2. You may modify your copy of the software in any way, provided that
|
10
|
+
you do at least ONE of the following:
|
11
|
+
|
12
|
+
a) place your modifications in the Public Domain or otherwise
|
13
|
+
make them Freely Available, such as by posting said
|
14
|
+
modifications to Usenet or an equivalent medium, or by allowing
|
15
|
+
the author to include your modifications in the software.
|
16
|
+
|
17
|
+
b) use the modified software only within your corporation or
|
18
|
+
organization.
|
19
|
+
|
20
|
+
c) give non-standard binaries non-standard names, with
|
21
|
+
instructions on where to get the original software distribution.
|
22
|
+
|
23
|
+
d) make other distribution arrangements with the author.
|
24
|
+
|
25
|
+
3. You may distribute the software in object code or binary form,
|
26
|
+
provided that you do at least ONE of the following:
|
27
|
+
|
28
|
+
a) distribute the binaries and library files of the software,
|
29
|
+
together with instructions (in the manual page or equivalent)
|
30
|
+
on where to get the original distribution.
|
31
|
+
|
32
|
+
b) accompany the distribution with the machine-readable source of
|
33
|
+
the software.
|
34
|
+
|
35
|
+
c) give non-standard binaries non-standard names, with
|
36
|
+
instructions on where to get the original software distribution.
|
37
|
+
|
38
|
+
d) make other distribution arrangements with the author.
|
39
|
+
|
40
|
+
4. You may modify and include the part of the software into any other
|
41
|
+
software (possibly commercial). But some files in the distribution
|
42
|
+
are not written by the author, so that they are not under these terms.
|
43
|
+
|
44
|
+
For the list of those files and their copying conditions, see the
|
45
|
+
file LEGAL.
|
46
|
+
|
47
|
+
5. The scripts and library files supplied as input to or produced as
|
48
|
+
output from the software do not automatically fall under the
|
49
|
+
copyright of the software, but belong to whomever generated them,
|
50
|
+
and may be sold commercially, and may be aggregated with this
|
51
|
+
software.
|
52
|
+
|
53
|
+
6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
|
54
|
+
IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
55
|
+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
56
|
+
PURPOSE.
|
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
# JSON implementation for Ruby
|
2
|
-
|
1
|
+
# JSON implementation for Ruby
|
2
|
+
|
3
|
+
[![Travis Widget](http://travis-ci.org/flori/json.svg?branch=master)](https://travis-ci.org/flori/json)
|
3
4
|
|
4
5
|
## Description
|
5
6
|
|
@@ -150,6 +151,18 @@ require 'json/add/rails'
|
|
150
151
|
Both of the additions attempt to require `'json'` (like above) first, if it has
|
151
152
|
not been required yet.
|
152
153
|
|
154
|
+
## Serializing exceptions
|
155
|
+
|
156
|
+
The JSON module doesn't extend `Exception` by default. If you convert an `Exception`
|
157
|
+
object to JSON, it will by default only include the exception message.
|
158
|
+
|
159
|
+
To include the full details, you must either load the `json/add/core` mentioned
|
160
|
+
above, or specifically load the exception addition:
|
161
|
+
|
162
|
+
```ruby
|
163
|
+
require 'json/add/exception'
|
164
|
+
```
|
165
|
+
|
153
166
|
## More Examples
|
154
167
|
|
155
168
|
To create a JSON document from a ruby data structure, you can call
|
@@ -179,14 +192,14 @@ should return a JSON object (a hash converted to JSON with `#to_json`) like
|
|
179
192
|
this (don't forget the `*a` for all the arguments):
|
180
193
|
|
181
194
|
```ruby
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
195
|
+
class Range
|
196
|
+
def to_json(*a)
|
197
|
+
{
|
198
|
+
'json_class' => self.class.name, # = 'Range'
|
199
|
+
'data' => [ first, last, exclude_end? ]
|
200
|
+
}.to_json(*a)
|
201
|
+
end
|
202
|
+
end
|
190
203
|
```
|
191
204
|
|
192
205
|
The hash key `json_class` is the class, that will be asked to deserialise the
|
@@ -194,26 +207,30 @@ JSON representation later. In this case it's `Range`, but any namespace of
|
|
194
207
|
the form `A::B` or `::A::B` will do. All other keys are arbitrary and can be
|
195
208
|
used to store the necessary data to configure the object to be deserialised.
|
196
209
|
|
197
|
-
If
|
210
|
+
If the key `json_class` is found in a JSON object, the JSON parser checks
|
198
211
|
if the given class responds to the `json_create` class method. If so, it is
|
199
212
|
called with the JSON object converted to a Ruby hash. So a range can
|
200
213
|
be deserialised by implementing `Range.json_create` like this:
|
201
214
|
|
202
215
|
```ruby
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
216
|
+
class Range
|
217
|
+
def self.json_create(o)
|
218
|
+
new(*o['data'])
|
219
|
+
end
|
220
|
+
end
|
208
221
|
```
|
209
222
|
|
210
223
|
Now it possible to serialise/deserialise ranges as well:
|
211
224
|
|
212
225
|
```ruby
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
226
|
+
json = JSON.generate [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
|
227
|
+
# => "[1,2,{\"a\":3.141},false,true,null,{\"json_class\":\"Range\",\"data\":[4,10,false]}]"
|
228
|
+
JSON.parse json
|
229
|
+
# => [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
|
230
|
+
json = JSON.generate [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
|
231
|
+
# => "[1,2,{\"a\":3.141},false,true,null,{\"json_class\":\"Range\",\"data\":[4,10,false]}]"
|
232
|
+
JSON.parse json, :create_additions => true
|
233
|
+
# => [1, 2, {"a"=>3.141}, false, true, nil, 4..10]
|
217
234
|
```
|
218
235
|
|
219
236
|
`JSON.generate` always creates the shortest possible string representation of a
|
@@ -389,4 +406,4 @@ The latest version of this library can be downloaded at
|
|
389
406
|
|
390
407
|
Online Documentation should be located at
|
391
408
|
|
392
|
-
*
|
409
|
+
* https://www.rubydoc.info/gems/json
|
data/Rakefile
CHANGED
@@ -23,8 +23,13 @@ class UndocumentedTestTask < Rake::TestTask
|
|
23
23
|
def desc(*) end
|
24
24
|
end
|
25
25
|
|
26
|
-
|
27
|
-
|
26
|
+
which = lambda { |c|
|
27
|
+
w = `which #{c}`
|
28
|
+
break w.chomp unless w.empty?
|
29
|
+
}
|
30
|
+
|
31
|
+
MAKE = ENV['MAKE'] || %w[gmake make].find(&which)
|
32
|
+
BUNDLE = ENV['BUNDLE'] || %w[bundle].find(&which)
|
28
33
|
PKG_NAME = 'json'
|
29
34
|
PKG_TITLE = 'JSON Implementation for Ruby'
|
30
35
|
PKG_VERSION = File.read('VERSION').chomp
|
@@ -47,8 +52,8 @@ JAVA_CLASSES = []
|
|
47
52
|
JRUBY_PARSER_JAR = File.expand_path("lib/json/ext/parser.jar")
|
48
53
|
JRUBY_GENERATOR_JAR = File.expand_path("lib/json/ext/generator.jar")
|
49
54
|
|
50
|
-
RAGEL_CODEGEN = %w[rlcodegen rlgen-cd ragel].find
|
51
|
-
RAGEL_DOTGEN = %w[rlgen-dot rlgen-cd ragel].find
|
55
|
+
RAGEL_CODEGEN = %w[rlcodegen rlgen-cd ragel].find(&which)
|
56
|
+
RAGEL_DOTGEN = %w[rlgen-dot rlgen-cd ragel].find(&which)
|
52
57
|
|
53
58
|
desc "Installing library (pure)"
|
54
59
|
task :install_pure => :version do
|
@@ -238,7 +243,7 @@ if defined?(RUBY_ENGINE) and RUBY_ENGINE == 'jruby'
|
|
238
243
|
classpath = (Dir['java/lib/*.jar'] << 'java/src' << JRUBY_JAR) * ':'
|
239
244
|
obj = src.sub(/\.java\Z/, '.class')
|
240
245
|
file obj => src do
|
241
|
-
sh 'javac', '-classpath', classpath, '-source', '1.
|
246
|
+
sh 'javac', '-classpath', classpath, '-source', '1.6', '-target', '1.6', src
|
242
247
|
end
|
243
248
|
JAVA_CLASSES << obj
|
244
249
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.3.0
|
@@ -15,7 +15,7 @@ static VALUE mJSON, mExt, mGenerator, cState, mGeneratorMethods, mObject,
|
|
15
15
|
#endif
|
16
16
|
mFloat, mString, mString_Extend,
|
17
17
|
mTrueClass, mFalseClass, mNilClass, eGeneratorError,
|
18
|
-
eNestingError,
|
18
|
+
eNestingError,
|
19
19
|
i_SAFE_STATE_PROTOTYPE;
|
20
20
|
|
21
21
|
static ID i_to_s, i_to_json, i_new, i_indent, i_space, i_space_before,
|
@@ -237,6 +237,7 @@ static void convert_UTF8_to_JSON(FBuffer *buffer, VALUE string)
|
|
237
237
|
int escape_len;
|
238
238
|
unsigned char c;
|
239
239
|
char buf[6] = { '\\', 'u' };
|
240
|
+
int ascii_only = rb_enc_str_asciionly_p(string);
|
240
241
|
|
241
242
|
for (start = 0, end = 0; end < len;) {
|
242
243
|
p = ptr + end;
|
@@ -281,14 +282,17 @@ static void convert_UTF8_to_JSON(FBuffer *buffer, VALUE string)
|
|
281
282
|
break;
|
282
283
|
default:
|
283
284
|
{
|
284
|
-
unsigned short clen =
|
285
|
-
if (
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
285
|
+
unsigned short clen = 1;
|
286
|
+
if (!ascii_only) {
|
287
|
+
clen += trailingBytesForUTF8[c];
|
288
|
+
if (end + clen > len) {
|
289
|
+
rb_raise(rb_path2class("JSON::GeneratorError"),
|
290
|
+
"partial character in source, but hit end");
|
291
|
+
}
|
292
|
+
if (!isLegalUTF8((UTF8 *) p, clen)) {
|
293
|
+
rb_raise(rb_path2class("JSON::GeneratorError"),
|
294
|
+
"source sequence is illegal/malformed utf-8");
|
295
|
+
}
|
292
296
|
}
|
293
297
|
end += clen;
|
294
298
|
}
|
@@ -692,7 +696,7 @@ static VALUE cState_aref(VALUE self, VALUE name)
|
|
692
696
|
if (RTEST(rb_funcall(self, i_respond_to_p, 1, name))) {
|
693
697
|
return rb_funcall(self, i_send, 1, name);
|
694
698
|
} else {
|
695
|
-
return
|
699
|
+
return rb_attr_get(self, rb_intern_str(rb_str_concat(rb_str_new2("@"), name)));
|
696
700
|
}
|
697
701
|
}
|
698
702
|
|
@@ -715,43 +719,83 @@ static VALUE cState_aset(VALUE self, VALUE name, VALUE value)
|
|
715
719
|
return Qnil;
|
716
720
|
}
|
717
721
|
|
718
|
-
|
722
|
+
struct hash_foreach_arg {
|
723
|
+
FBuffer *buffer;
|
724
|
+
JSON_Generator_State *state;
|
725
|
+
VALUE Vstate;
|
726
|
+
int iter;
|
727
|
+
};
|
728
|
+
|
729
|
+
static int
|
730
|
+
json_object_i(VALUE key, VALUE val, VALUE _arg)
|
719
731
|
{
|
732
|
+
struct hash_foreach_arg *arg = (struct hash_foreach_arg *)_arg;
|
733
|
+
FBuffer *buffer = arg->buffer;
|
734
|
+
JSON_Generator_State *state = arg->state;
|
735
|
+
VALUE Vstate = arg->Vstate;
|
736
|
+
|
720
737
|
char *object_nl = state->object_nl;
|
721
738
|
long object_nl_len = state->object_nl_len;
|
722
739
|
char *indent = state->indent;
|
723
740
|
long indent_len = state->indent_len;
|
724
|
-
long max_nesting = state->max_nesting;
|
725
741
|
char *delim = FBUFFER_PTR(state->object_delim);
|
726
742
|
long delim_len = FBUFFER_LEN(state->object_delim);
|
727
743
|
char *delim2 = FBUFFER_PTR(state->object_delim2);
|
728
744
|
long delim2_len = FBUFFER_LEN(state->object_delim2);
|
745
|
+
long depth = state->depth;
|
746
|
+
int j;
|
747
|
+
VALUE klass, key_to_s;
|
748
|
+
|
749
|
+
if (arg->iter > 0) fbuffer_append(buffer, delim, delim_len);
|
750
|
+
if (object_nl) {
|
751
|
+
fbuffer_append(buffer, object_nl, object_nl_len);
|
752
|
+
}
|
753
|
+
if (indent) {
|
754
|
+
for (j = 0; j < depth; j++) {
|
755
|
+
fbuffer_append(buffer, indent, indent_len);
|
756
|
+
}
|
757
|
+
}
|
758
|
+
|
759
|
+
klass = CLASS_OF(key);
|
760
|
+
if (klass == rb_cString) {
|
761
|
+
key_to_s = key;
|
762
|
+
} else if (klass == rb_cSymbol) {
|
763
|
+
key_to_s = rb_id2str(SYM2ID(key));
|
764
|
+
} else {
|
765
|
+
key_to_s = rb_funcall(key, i_to_s, 0);
|
766
|
+
}
|
767
|
+
Check_Type(key_to_s, T_STRING);
|
768
|
+
generate_json(buffer, Vstate, state, key_to_s);
|
769
|
+
fbuffer_append(buffer, delim2, delim2_len);
|
770
|
+
generate_json(buffer, Vstate, state, val);
|
771
|
+
|
772
|
+
arg->iter++;
|
773
|
+
return ST_CONTINUE;
|
774
|
+
}
|
775
|
+
|
776
|
+
static void generate_json_object(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
|
777
|
+
{
|
778
|
+
char *object_nl = state->object_nl;
|
779
|
+
long object_nl_len = state->object_nl_len;
|
780
|
+
char *indent = state->indent;
|
781
|
+
long indent_len = state->indent_len;
|
782
|
+
long max_nesting = state->max_nesting;
|
729
783
|
long depth = ++state->depth;
|
730
|
-
int
|
731
|
-
|
784
|
+
int j;
|
785
|
+
struct hash_foreach_arg arg;
|
786
|
+
|
732
787
|
if (max_nesting != 0 && depth > max_nesting) {
|
733
788
|
fbuffer_free(buffer);
|
734
789
|
rb_raise(eNestingError, "nesting of %ld is too deep", --state->depth);
|
735
790
|
}
|
736
791
|
fbuffer_append_char(buffer, '{');
|
737
|
-
|
738
|
-
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
for (j = 0; j < depth; j++) {
|
745
|
-
fbuffer_append(buffer, indent, indent_len);
|
746
|
-
}
|
747
|
-
}
|
748
|
-
key = rb_ary_entry(keys, i);
|
749
|
-
key_to_s = rb_funcall(key, i_to_s, 0);
|
750
|
-
Check_Type(key_to_s, T_STRING);
|
751
|
-
generate_json(buffer, Vstate, state, key_to_s);
|
752
|
-
fbuffer_append(buffer, delim2, delim2_len);
|
753
|
-
generate_json(buffer, Vstate, state, rb_hash_aref(obj, key));
|
754
|
-
}
|
792
|
+
|
793
|
+
arg.buffer = buffer;
|
794
|
+
arg.state = state;
|
795
|
+
arg.Vstate = Vstate;
|
796
|
+
arg.iter = 0;
|
797
|
+
rb_hash_foreach(obj, json_object_i, (VALUE)&arg);
|
798
|
+
|
755
799
|
depth = --state->depth;
|
756
800
|
if (object_nl) {
|
757
801
|
fbuffer_append(buffer, object_nl, object_nl_len);
|
@@ -802,11 +846,22 @@ static void generate_json_array(FBuffer *buffer, VALUE Vstate, JSON_Generator_St
|
|
802
846
|
fbuffer_append_char(buffer, ']');
|
803
847
|
}
|
804
848
|
|
849
|
+
#ifdef HAVE_RUBY_ENCODING_H
|
850
|
+
static int enc_utf8_compatible_p(rb_encoding *enc)
|
851
|
+
{
|
852
|
+
if (enc == rb_usascii_encoding()) return 1;
|
853
|
+
if (enc == rb_utf8_encoding()) return 1;
|
854
|
+
return 0;
|
855
|
+
}
|
856
|
+
#endif
|
857
|
+
|
805
858
|
static void generate_json_string(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj)
|
806
859
|
{
|
807
860
|
fbuffer_append_char(buffer, '"');
|
808
861
|
#ifdef HAVE_RUBY_ENCODING_H
|
809
|
-
|
862
|
+
if (!enc_utf8_compatible_p(rb_enc_get(obj))) {
|
863
|
+
obj = rb_str_encode(obj, CEncoding_UTF_8, 0, Qnil);
|
864
|
+
}
|
810
865
|
#endif
|
811
866
|
if (state->ascii_only) {
|
812
867
|
convert_UTF8_to_JSON_ASCII(buffer, obj);
|
@@ -970,6 +1025,8 @@ static VALUE cState_generate(VALUE self, VALUE obj)
|
|
970
1025
|
* * *allow_nan*: true if NaN, Infinity, and -Infinity should be
|
971
1026
|
* generated, otherwise an exception is thrown, if these values are
|
972
1027
|
* encountered. This options defaults to false.
|
1028
|
+
* * *ascii_only*: true if only ASCII characters should be generated. This
|
1029
|
+
* ontions defaults to false.
|
973
1030
|
* * *buffer_initial_length*: sets the initial length of the generator's
|
974
1031
|
* internal buffer.
|
975
1032
|
*/
|
@@ -1025,10 +1082,8 @@ static VALUE cState_from_state_s(VALUE self, VALUE opts)
|
|
1025
1082
|
} else if (rb_obj_is_kind_of(opts, rb_cHash)) {
|
1026
1083
|
return rb_funcall(self, i_new, 1, opts);
|
1027
1084
|
} else {
|
1028
|
-
|
1029
|
-
|
1030
|
-
}
|
1031
|
-
return rb_funcall(CJSON_SAFE_STATE_PROTOTYPE, i_dup, 0);
|
1085
|
+
VALUE prototype = rb_const_get(mJSON, i_SAFE_STATE_PROTOTYPE);
|
1086
|
+
return rb_funcall(prototype, i_dup, 0);
|
1032
1087
|
}
|
1033
1088
|
}
|
1034
1089
|
|
@@ -1267,7 +1322,7 @@ static VALUE cState_allow_nan_p(VALUE self)
|
|
1267
1322
|
/*
|
1268
1323
|
* call-seq: ascii_only?
|
1269
1324
|
*
|
1270
|
-
* Returns true, if
|
1325
|
+
* Returns true, if only ASCII characters should be generated. Otherwise
|
1271
1326
|
* returns false.
|
1272
1327
|
*/
|
1273
1328
|
static VALUE cState_ascii_only_p(VALUE self)
|
@@ -1335,6 +1390,7 @@ static VALUE cState_buffer_initial_length_set(VALUE self, VALUE buffer_initial_l
|
|
1335
1390
|
*/
|
1336
1391
|
void Init_generator(void)
|
1337
1392
|
{
|
1393
|
+
#undef rb_intern
|
1338
1394
|
rb_require("json/common");
|
1339
1395
|
|
1340
1396
|
mJSON = rb_define_module("JSON");
|
@@ -1343,6 +1399,8 @@ void Init_generator(void)
|
|
1343
1399
|
|
1344
1400
|
eGeneratorError = rb_path2class("JSON::GeneratorError");
|
1345
1401
|
eNestingError = rb_path2class("JSON::NestingError");
|
1402
|
+
rb_gc_register_mark_object(eGeneratorError);
|
1403
|
+
rb_gc_register_mark_object(eNestingError);
|
1346
1404
|
|
1347
1405
|
cState = rb_define_class_under(mGenerator, "State", rb_cObject);
|
1348
1406
|
rb_define_alloc_func(cState, cState_s_allocate);
|
@@ -1408,7 +1466,6 @@ void Init_generator(void)
|
|
1408
1466
|
mNilClass = rb_define_module_under(mGeneratorMethods, "NilClass");
|
1409
1467
|
rb_define_method(mNilClass, "to_json", mNilClass_to_json, -1);
|
1410
1468
|
|
1411
|
-
CRegexp_MULTILINE = rb_const_get(rb_cRegexp, rb_intern("MULTILINE"));
|
1412
1469
|
i_to_s = rb_intern("to_s");
|
1413
1470
|
i_to_json = rb_intern("to_json");
|
1414
1471
|
i_new = rb_intern("new");
|
@@ -1439,5 +1496,4 @@ void Init_generator(void)
|
|
1439
1496
|
i_encode = rb_intern("encode");
|
1440
1497
|
#endif
|
1441
1498
|
i_SAFE_STATE_PROTOTYPE = rb_intern("SAFE_STATE_PROTOTYPE");
|
1442
|
-
CJSON_SAFE_STATE_PROTOTYPE = Qnil;
|
1443
1499
|
}
|