json 2.2.0

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.

Files changed (107) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +17 -0
  3. data/.travis.yml +23 -0
  4. data/CHANGES.md +391 -0
  5. data/Gemfile +14 -0
  6. data/README-json-jruby.md +33 -0
  7. data/README.md +409 -0
  8. data/Rakefile +408 -0
  9. data/VERSION +1 -0
  10. data/diagrams/.keep +0 -0
  11. data/ext/json/ext/fbuffer/fbuffer.h +187 -0
  12. data/ext/json/ext/generator/depend +1 -0
  13. data/ext/json/ext/generator/extconf.rb +4 -0
  14. data/ext/json/ext/generator/generator.c +1444 -0
  15. data/ext/json/ext/generator/generator.h +171 -0
  16. data/ext/json/ext/parser/depend +1 -0
  17. data/ext/json/ext/parser/extconf.rb +6 -0
  18. data/ext/json/ext/parser/parser.c +2131 -0
  19. data/ext/json/ext/parser/parser.h +91 -0
  20. data/ext/json/ext/parser/parser.rl +891 -0
  21. data/ext/json/extconf.rb +2 -0
  22. data/install.rb +23 -0
  23. data/java/src/json/ext/ByteListTranscoder.java +166 -0
  24. data/java/src/json/ext/Generator.java +443 -0
  25. data/java/src/json/ext/GeneratorMethods.java +231 -0
  26. data/java/src/json/ext/GeneratorService.java +42 -0
  27. data/java/src/json/ext/GeneratorState.java +490 -0
  28. data/java/src/json/ext/OptionsReader.java +113 -0
  29. data/java/src/json/ext/Parser.java +2362 -0
  30. data/java/src/json/ext/Parser.rl +893 -0
  31. data/java/src/json/ext/ParserService.java +34 -0
  32. data/java/src/json/ext/RuntimeInfo.java +116 -0
  33. data/java/src/json/ext/StringDecoder.java +166 -0
  34. data/java/src/json/ext/StringEncoder.java +111 -0
  35. data/java/src/json/ext/Utils.java +88 -0
  36. data/json-java.gemspec +38 -0
  37. data/json.gemspec +0 -0
  38. data/json_pure.gemspec +38 -0
  39. data/lib/json.rb +63 -0
  40. data/lib/json/add/bigdecimal.rb +29 -0
  41. data/lib/json/add/complex.rb +29 -0
  42. data/lib/json/add/core.rb +12 -0
  43. data/lib/json/add/date.rb +34 -0
  44. data/lib/json/add/date_time.rb +50 -0
  45. data/lib/json/add/exception.rb +31 -0
  46. data/lib/json/add/ostruct.rb +31 -0
  47. data/lib/json/add/range.rb +29 -0
  48. data/lib/json/add/rational.rb +28 -0
  49. data/lib/json/add/regexp.rb +30 -0
  50. data/lib/json/add/set.rb +29 -0
  51. data/lib/json/add/struct.rb +30 -0
  52. data/lib/json/add/symbol.rb +25 -0
  53. data/lib/json/add/time.rb +38 -0
  54. data/lib/json/common.rb +456 -0
  55. data/lib/json/ext.rb +15 -0
  56. data/lib/json/ext/.keep +0 -0
  57. data/lib/json/generic_object.rb +71 -0
  58. data/lib/json/pure.rb +15 -0
  59. data/lib/json/pure/generator.rb +458 -0
  60. data/lib/json/pure/parser.rb +311 -0
  61. data/lib/json/version.rb +9 -0
  62. data/references/rfc7159.txt +899 -0
  63. data/tests/fixtures/fail10.json +1 -0
  64. data/tests/fixtures/fail11.json +1 -0
  65. data/tests/fixtures/fail12.json +1 -0
  66. data/tests/fixtures/fail13.json +1 -0
  67. data/tests/fixtures/fail14.json +1 -0
  68. data/tests/fixtures/fail18.json +1 -0
  69. data/tests/fixtures/fail19.json +1 -0
  70. data/tests/fixtures/fail2.json +1 -0
  71. data/tests/fixtures/fail20.json +1 -0
  72. data/tests/fixtures/fail21.json +1 -0
  73. data/tests/fixtures/fail22.json +1 -0
  74. data/tests/fixtures/fail23.json +1 -0
  75. data/tests/fixtures/fail24.json +1 -0
  76. data/tests/fixtures/fail25.json +1 -0
  77. data/tests/fixtures/fail27.json +2 -0
  78. data/tests/fixtures/fail28.json +2 -0
  79. data/tests/fixtures/fail3.json +1 -0
  80. data/tests/fixtures/fail4.json +1 -0
  81. data/tests/fixtures/fail5.json +1 -0
  82. data/tests/fixtures/fail6.json +1 -0
  83. data/tests/fixtures/fail7.json +1 -0
  84. data/tests/fixtures/fail8.json +1 -0
  85. data/tests/fixtures/fail9.json +1 -0
  86. data/tests/fixtures/obsolete_fail1.json +1 -0
  87. data/tests/fixtures/pass1.json +56 -0
  88. data/tests/fixtures/pass15.json +1 -0
  89. data/tests/fixtures/pass16.json +1 -0
  90. data/tests/fixtures/pass17.json +1 -0
  91. data/tests/fixtures/pass2.json +1 -0
  92. data/tests/fixtures/pass26.json +1 -0
  93. data/tests/fixtures/pass3.json +6 -0
  94. data/tests/json_addition_test.rb +203 -0
  95. data/tests/json_common_interface_test.rb +126 -0
  96. data/tests/json_encoding_test.rb +107 -0
  97. data/tests/json_ext_parser_test.rb +15 -0
  98. data/tests/json_fixtures_test.rb +32 -0
  99. data/tests/json_generator_test.rb +377 -0
  100. data/tests/json_generic_object_test.rb +82 -0
  101. data/tests/json_parser_test.rb +472 -0
  102. data/tests/json_string_matching_test.rb +38 -0
  103. data/tests/test_helper.rb +17 -0
  104. data/tools/diff.sh +18 -0
  105. data/tools/fuzz.rb +131 -0
  106. data/tools/server.rb +62 -0
  107. metadata +185 -0
@@ -0,0 +1,15 @@
1
+ require 'json/common'
2
+
3
+ module JSON
4
+ # This module holds all the modules/classes that implement JSON's
5
+ # functionality as C extensions.
6
+ module Ext
7
+ require 'json/ext/parser'
8
+ require 'json/ext/generator'
9
+ $DEBUG and warn "Using Ext extension for JSON."
10
+ JSON.parser = Parser
11
+ JSON.generator = Generator
12
+ end
13
+
14
+ JSON_LOADED = true unless defined?(::JSON::JSON_LOADED)
15
+ end
File without changes
@@ -0,0 +1,71 @@
1
+ #frozen_string_literal: false
2
+ require 'ostruct'
3
+
4
+ module JSON
5
+ class GenericObject < OpenStruct
6
+ class << self
7
+ alias [] new
8
+
9
+ def json_creatable?
10
+ @json_creatable
11
+ end
12
+
13
+ attr_writer :json_creatable
14
+
15
+ def json_create(data)
16
+ data = data.dup
17
+ data.delete JSON.create_id
18
+ self[data]
19
+ end
20
+
21
+ def from_hash(object)
22
+ case
23
+ when object.respond_to?(:to_hash)
24
+ result = new
25
+ object.to_hash.each do |key, value|
26
+ result[key] = from_hash(value)
27
+ end
28
+ result
29
+ when object.respond_to?(:to_ary)
30
+ object.to_ary.map { |a| from_hash(a) }
31
+ else
32
+ object
33
+ end
34
+ end
35
+
36
+ def load(source, proc = nil, opts = {})
37
+ result = ::JSON.load(source, proc, opts.merge(:object_class => self))
38
+ result.nil? ? new : result
39
+ end
40
+
41
+ def dump(obj, *args)
42
+ ::JSON.dump(obj, *args)
43
+ end
44
+ end
45
+ self.json_creatable = false
46
+
47
+ def to_hash
48
+ table
49
+ end
50
+
51
+ def [](name)
52
+ __send__(name)
53
+ end unless method_defined?(:[])
54
+
55
+ def []=(name, value)
56
+ __send__("#{name}=", value)
57
+ end unless method_defined?(:[]=)
58
+
59
+ def |(other)
60
+ self.class[other.to_hash.merge(to_hash)]
61
+ end
62
+
63
+ def as_json(*)
64
+ { JSON.create_id => self.class.name }.merge to_hash
65
+ end
66
+
67
+ def to_json(*a)
68
+ as_json.to_json(*a)
69
+ end
70
+ end
71
+ end
@@ -0,0 +1,15 @@
1
+ require 'json/common'
2
+
3
+ module JSON
4
+ # This module holds all the modules/classes that implement JSON's
5
+ # functionality in pure ruby.
6
+ module Pure
7
+ require 'json/pure/parser'
8
+ require 'json/pure/generator'
9
+ $DEBUG and warn "Using Pure library for JSON."
10
+ JSON.parser = Parser
11
+ JSON.generator = Generator
12
+ end
13
+
14
+ JSON_LOADED = true unless defined?(::JSON::JSON_LOADED)
15
+ end
@@ -0,0 +1,458 @@
1
+ #frozen_string_literal: false
2
+ module JSON
3
+ MAP = {
4
+ "\x0" => '\u0000',
5
+ "\x1" => '\u0001',
6
+ "\x2" => '\u0002',
7
+ "\x3" => '\u0003',
8
+ "\x4" => '\u0004',
9
+ "\x5" => '\u0005',
10
+ "\x6" => '\u0006',
11
+ "\x7" => '\u0007',
12
+ "\b" => '\b',
13
+ "\t" => '\t',
14
+ "\n" => '\n',
15
+ "\xb" => '\u000b',
16
+ "\f" => '\f',
17
+ "\r" => '\r',
18
+ "\xe" => '\u000e',
19
+ "\xf" => '\u000f',
20
+ "\x10" => '\u0010',
21
+ "\x11" => '\u0011',
22
+ "\x12" => '\u0012',
23
+ "\x13" => '\u0013',
24
+ "\x14" => '\u0014',
25
+ "\x15" => '\u0015',
26
+ "\x16" => '\u0016',
27
+ "\x17" => '\u0017',
28
+ "\x18" => '\u0018',
29
+ "\x19" => '\u0019',
30
+ "\x1a" => '\u001a',
31
+ "\x1b" => '\u001b',
32
+ "\x1c" => '\u001c',
33
+ "\x1d" => '\u001d',
34
+ "\x1e" => '\u001e',
35
+ "\x1f" => '\u001f',
36
+ '"' => '\"',
37
+ '\\' => '\\\\',
38
+ } # :nodoc:
39
+
40
+ # Convert a UTF8 encoded Ruby string _string_ to a JSON string, encoded with
41
+ # UTF16 big endian characters as \u????, and return it.
42
+ def utf8_to_json(string) # :nodoc:
43
+ string = string.dup
44
+ string.force_encoding(::Encoding::ASCII_8BIT)
45
+ string.gsub!(/["\\\x0-\x1f]/) { MAP[$&] }
46
+ string.force_encoding(::Encoding::UTF_8)
47
+ string
48
+ end
49
+
50
+ def utf8_to_json_ascii(string) # :nodoc:
51
+ string = string.dup
52
+ string.force_encoding(::Encoding::ASCII_8BIT)
53
+ string.gsub!(/["\\\x0-\x1f]/n) { MAP[$&] }
54
+ string.gsub!(/(
55
+ (?:
56
+ [\xc2-\xdf][\x80-\xbf] |
57
+ [\xe0-\xef][\x80-\xbf]{2} |
58
+ [\xf0-\xf4][\x80-\xbf]{3}
59
+ )+ |
60
+ [\x80-\xc1\xf5-\xff] # invalid
61
+ )/nx) { |c|
62
+ c.size == 1 and raise GeneratorError, "invalid utf8 byte: '#{c}'"
63
+ s = JSON.iconv('utf-16be', 'utf-8', c).unpack('H*')[0]
64
+ s.force_encoding(::Encoding::ASCII_8BIT)
65
+ s.gsub!(/.{4}/n, '\\\\u\&')
66
+ s.force_encoding(::Encoding::UTF_8)
67
+ }
68
+ string.force_encoding(::Encoding::UTF_8)
69
+ string
70
+ rescue => e
71
+ raise GeneratorError.wrap(e)
72
+ end
73
+
74
+ def valid_utf8?(string)
75
+ encoding = string.encoding
76
+ (encoding == Encoding::UTF_8 || encoding == Encoding::ASCII) &&
77
+ string.valid_encoding?
78
+ end
79
+ module_function :utf8_to_json, :utf8_to_json_ascii, :valid_utf8?
80
+
81
+ module Pure
82
+ module Generator
83
+ # This class is used to create State instances, that are use to hold data
84
+ # while generating a JSON text from a Ruby data structure.
85
+ class State
86
+ # Creates a State object from _opts_, which ought to be Hash to create
87
+ # a new State instance configured by _opts_, something else to create
88
+ # an unconfigured instance. If _opts_ is a State object, it is just
89
+ # returned.
90
+ def self.from_state(opts)
91
+ case
92
+ when self === opts
93
+ opts
94
+ when opts.respond_to?(:to_hash)
95
+ new(opts.to_hash)
96
+ when opts.respond_to?(:to_h)
97
+ new(opts.to_h)
98
+ else
99
+ SAFE_STATE_PROTOTYPE.dup
100
+ end
101
+ end
102
+
103
+ # Instantiates a new State object, configured by _opts_.
104
+ #
105
+ # _opts_ can have the following keys:
106
+ #
107
+ # * *indent*: a string used to indent levels (default: ''),
108
+ # * *space*: a string that is put after, a : or , delimiter (default: ''),
109
+ # * *space_before*: a string that is put before a : pair delimiter (default: ''),
110
+ # * *object_nl*: a string that is put at the end of a JSON object (default: ''),
111
+ # * *array_nl*: a string that is put at the end of a JSON array (default: ''),
112
+ # * *check_circular*: is deprecated now, use the :max_nesting option instead,
113
+ # * *max_nesting*: sets the maximum level of data structure nesting in
114
+ # the generated JSON, max_nesting = 0 if no maximum should be checked.
115
+ # * *allow_nan*: true if NaN, Infinity, and -Infinity should be
116
+ # generated, otherwise an exception is thrown, if these values are
117
+ # encountered. This options defaults to false.
118
+ def initialize(opts = {})
119
+ @indent = ''
120
+ @space = ''
121
+ @space_before = ''
122
+ @object_nl = ''
123
+ @array_nl = ''
124
+ @allow_nan = false
125
+ @ascii_only = false
126
+ @buffer_initial_length = 1024
127
+ configure opts
128
+ end
129
+
130
+ # This string is used to indent levels in the JSON text.
131
+ attr_accessor :indent
132
+
133
+ # This string is used to insert a space between the tokens in a JSON
134
+ # string.
135
+ attr_accessor :space
136
+
137
+ # This string is used to insert a space before the ':' in JSON objects.
138
+ attr_accessor :space_before
139
+
140
+ # This string is put at the end of a line that holds a JSON object (or
141
+ # Hash).
142
+ attr_accessor :object_nl
143
+
144
+ # This string is put at the end of a line that holds a JSON array.
145
+ attr_accessor :array_nl
146
+
147
+ # This integer returns the maximum level of data structure nesting in
148
+ # the generated JSON, max_nesting = 0 if no maximum is checked.
149
+ attr_accessor :max_nesting
150
+
151
+ # :stopdoc:
152
+ attr_reader :buffer_initial_length
153
+
154
+ def buffer_initial_length=(length)
155
+ if length > 0
156
+ @buffer_initial_length = length
157
+ end
158
+ end
159
+ # :startdoc:
160
+
161
+ # This integer returns the current depth data structure nesting in the
162
+ # generated JSON.
163
+ attr_accessor :depth
164
+
165
+ def check_max_nesting # :nodoc:
166
+ return if @max_nesting.zero?
167
+ current_nesting = depth + 1
168
+ current_nesting > @max_nesting and
169
+ raise NestingError, "nesting of #{current_nesting} is too deep"
170
+ end
171
+
172
+ # Returns true, if circular data structures are checked,
173
+ # otherwise returns false.
174
+ def check_circular?
175
+ !@max_nesting.zero?
176
+ end
177
+
178
+ # Returns true if NaN, Infinity, and -Infinity should be considered as
179
+ # valid JSON and output.
180
+ def allow_nan?
181
+ @allow_nan
182
+ end
183
+
184
+ # Returns true, if only ASCII characters should be generated. Otherwise
185
+ # returns false.
186
+ def ascii_only?
187
+ @ascii_only
188
+ end
189
+
190
+ # Configure this State instance with the Hash _opts_, and return
191
+ # itself.
192
+ def configure(opts)
193
+ if opts.respond_to?(:to_hash)
194
+ opts = opts.to_hash
195
+ elsif opts.respond_to?(:to_h)
196
+ opts = opts.to_h
197
+ else
198
+ raise TypeError, "can't convert #{opts.class} into Hash"
199
+ end
200
+ for key, value in opts
201
+ instance_variable_set "@#{key}", value
202
+ end
203
+ @indent = opts[:indent] if opts.key?(:indent)
204
+ @space = opts[:space] if opts.key?(:space)
205
+ @space_before = opts[:space_before] if opts.key?(:space_before)
206
+ @object_nl = opts[:object_nl] if opts.key?(:object_nl)
207
+ @array_nl = opts[:array_nl] if opts.key?(:array_nl)
208
+ @allow_nan = !!opts[:allow_nan] if opts.key?(:allow_nan)
209
+ @ascii_only = opts[:ascii_only] if opts.key?(:ascii_only)
210
+ @depth = opts[:depth] || 0
211
+ @buffer_initial_length ||= opts[:buffer_initial_length]
212
+
213
+ if !opts.key?(:max_nesting) # defaults to 100
214
+ @max_nesting = 100
215
+ elsif opts[:max_nesting]
216
+ @max_nesting = opts[:max_nesting]
217
+ else
218
+ @max_nesting = 0
219
+ end
220
+ self
221
+ end
222
+ alias merge configure
223
+
224
+ # Returns the configuration instance variables as a hash, that can be
225
+ # passed to the configure method.
226
+ def to_h
227
+ result = {}
228
+ for iv in instance_variables
229
+ iv = iv.to_s[1..-1]
230
+ result[iv.to_sym] = self[iv]
231
+ end
232
+ result
233
+ end
234
+
235
+ alias to_hash to_h
236
+
237
+ # Generates a valid JSON document from object +obj+ and
238
+ # returns the result. If no valid JSON document can be
239
+ # created this method raises a
240
+ # GeneratorError exception.
241
+ def generate(obj)
242
+ result = obj.to_json(self)
243
+ JSON.valid_utf8?(result) or raise GeneratorError,
244
+ "source sequence #{result.inspect} is illegal/malformed utf-8"
245
+ result
246
+ end
247
+
248
+ # Return the value returned by method +name+.
249
+ def [](name)
250
+ if respond_to?(name)
251
+ __send__(name)
252
+ else
253
+ instance_variable_get("@#{name}")
254
+ end
255
+ end
256
+
257
+ def []=(name, value)
258
+ if respond_to?(name_writer = "#{name}=")
259
+ __send__ name_writer, value
260
+ else
261
+ instance_variable_set "@#{name}", value
262
+ end
263
+ end
264
+ end
265
+
266
+ module GeneratorMethods
267
+ module Object
268
+ # Converts this object to a string (calling #to_s), converts
269
+ # it to a JSON string, and returns the result. This is a fallback, if no
270
+ # special method #to_json was defined for some object.
271
+ def to_json(*) to_s.to_json end
272
+ end
273
+
274
+ module Hash
275
+ # Returns a JSON string containing a JSON object, that is unparsed from
276
+ # this Hash instance.
277
+ # _state_ is a JSON::State object, that can also be used to configure the
278
+ # produced JSON string output further.
279
+ # _depth_ is used to find out nesting depth, to indent accordingly.
280
+ def to_json(state = nil, *)
281
+ state = State.from_state(state)
282
+ state.check_max_nesting
283
+ json_transform(state)
284
+ end
285
+
286
+ private
287
+
288
+ def json_shift(state)
289
+ state.object_nl.empty? or return ''
290
+ state.indent * state.depth
291
+ end
292
+
293
+ def json_transform(state)
294
+ delim = ','
295
+ delim << state.object_nl
296
+ result = '{'
297
+ result << state.object_nl
298
+ depth = state.depth += 1
299
+ first = true
300
+ indent = !state.object_nl.empty?
301
+ each { |key,value|
302
+ result << delim unless first
303
+ result << state.indent * depth if indent
304
+ result << key.to_s.to_json(state)
305
+ result << state.space_before
306
+ result << ':'
307
+ result << state.space
308
+ if value.respond_to?(:to_json)
309
+ result << value.to_json(state)
310
+ else
311
+ result << %{"#{String(value)}"}
312
+ end
313
+ first = false
314
+ }
315
+ depth = state.depth -= 1
316
+ result << state.object_nl
317
+ result << state.indent * depth if indent
318
+ result << '}'
319
+ result
320
+ end
321
+ end
322
+
323
+ module Array
324
+ # Returns a JSON string containing a JSON array, that is unparsed from
325
+ # this Array instance.
326
+ # _state_ is a JSON::State object, that can also be used to configure the
327
+ # produced JSON string output further.
328
+ def to_json(state = nil, *)
329
+ state = State.from_state(state)
330
+ state.check_max_nesting
331
+ json_transform(state)
332
+ end
333
+
334
+ private
335
+
336
+ def json_transform(state)
337
+ delim = ','
338
+ delim << state.array_nl
339
+ result = '['
340
+ result << state.array_nl
341
+ depth = state.depth += 1
342
+ first = true
343
+ indent = !state.array_nl.empty?
344
+ each { |value|
345
+ result << delim unless first
346
+ result << state.indent * depth if indent
347
+ if value.respond_to?(:to_json)
348
+ result << value.to_json(state)
349
+ else
350
+ result << %{"#{String(value)}"}
351
+ end
352
+ first = false
353
+ }
354
+ depth = state.depth -= 1
355
+ result << state.array_nl
356
+ result << state.indent * depth if indent
357
+ result << ']'
358
+ end
359
+ end
360
+
361
+ module Integer
362
+ # Returns a JSON string representation for this Integer number.
363
+ def to_json(*) to_s end
364
+ end
365
+
366
+ module Float
367
+ # Returns a JSON string representation for this Float number.
368
+ def to_json(state = nil, *)
369
+ state = State.from_state(state)
370
+ case
371
+ when infinite?
372
+ if state.allow_nan?
373
+ to_s
374
+ else
375
+ raise GeneratorError, "#{self} not allowed in JSON"
376
+ end
377
+ when nan?
378
+ if state.allow_nan?
379
+ to_s
380
+ else
381
+ raise GeneratorError, "#{self} not allowed in JSON"
382
+ end
383
+ else
384
+ to_s
385
+ end
386
+ end
387
+ end
388
+
389
+ module String
390
+ # This string should be encoded with UTF-8 A call to this method
391
+ # returns a JSON string encoded with UTF16 big endian characters as
392
+ # \u????.
393
+ def to_json(state = nil, *args)
394
+ state = State.from_state(state)
395
+ if encoding == ::Encoding::UTF_8
396
+ string = self
397
+ else
398
+ string = encode(::Encoding::UTF_8)
399
+ end
400
+ if state.ascii_only?
401
+ '"' << JSON.utf8_to_json_ascii(string) << '"'
402
+ else
403
+ '"' << JSON.utf8_to_json(string) << '"'
404
+ end
405
+ end
406
+
407
+ # Module that holds the extinding methods if, the String module is
408
+ # included.
409
+ module Extend
410
+ # Raw Strings are JSON Objects (the raw bytes are stored in an
411
+ # array for the key "raw"). The Ruby String can be created by this
412
+ # module method.
413
+ def json_create(o)
414
+ o['raw'].pack('C*')
415
+ end
416
+ end
417
+
418
+ # Extends _modul_ with the String::Extend module.
419
+ def self.included(modul)
420
+ modul.extend Extend
421
+ end
422
+
423
+ # This method creates a raw object hash, that can be nested into
424
+ # other data structures and will be unparsed as a raw string. This
425
+ # method should be used, if you want to convert raw strings to JSON
426
+ # instead of UTF-8 strings, e. g. binary data.
427
+ def to_json_raw_object
428
+ {
429
+ JSON.create_id => self.class.name,
430
+ 'raw' => self.unpack('C*'),
431
+ }
432
+ end
433
+
434
+ # This method creates a JSON text from the result of
435
+ # a call to to_json_raw_object of this String.
436
+ def to_json_raw(*args)
437
+ to_json_raw_object.to_json(*args)
438
+ end
439
+ end
440
+
441
+ module TrueClass
442
+ # Returns a JSON string for true: 'true'.
443
+ def to_json(*) 'true' end
444
+ end
445
+
446
+ module FalseClass
447
+ # Returns a JSON string for false: 'false'.
448
+ def to_json(*) 'false' end
449
+ end
450
+
451
+ module NilClass
452
+ # Returns a JSON string for nil: 'null'.
453
+ def to_json(*) 'null' end
454
+ end
455
+ end
456
+ end
457
+ end
458
+ end