json 2.7.5 → 2.9.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,101 +1,111 @@
1
1
  # frozen_string_literal: true
2
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
- }.freeze # :nodoc:
39
-
40
- ESCAPE_PATTERN = /[\/"\\\x0-\x1f]/n # :nodoc:
41
-
42
- SCRIPT_SAFE_MAP = MAP.merge(
43
- '/' => '\\/',
44
- "\u2028".b => '\u2028',
45
- "\u2029".b => '\u2029',
46
- ).freeze
47
-
48
- SCRIPT_SAFE_ESCAPE_PATTERN = Regexp.union(ESCAPE_PATTERN, "\u2028".b, "\u2029".b)
49
-
50
- # Convert a UTF8 encoded Ruby string _string_ to a JSON string, encoded with
51
- # UTF16 big endian characters as \u????, and return it.
52
- def utf8_to_json(string, script_safe = false) # :nodoc:
53
- string = string.b
54
- if script_safe
55
- string.gsub!(SCRIPT_SAFE_ESCAPE_PATTERN) { SCRIPT_SAFE_MAP[$&] || $& }
56
- else
57
- string.gsub!(ESCAPE_PATTERN) { MAP[$&] || $& }
58
- end
59
- string.force_encoding(::Encoding::UTF_8)
60
- string
61
- end
3
+ module TruffleRuby
4
+ module Generator
5
+ MAP = {
6
+ "\x0" => '\u0000',
7
+ "\x1" => '\u0001',
8
+ "\x2" => '\u0002',
9
+ "\x3" => '\u0003',
10
+ "\x4" => '\u0004',
11
+ "\x5" => '\u0005',
12
+ "\x6" => '\u0006',
13
+ "\x7" => '\u0007',
14
+ "\b" => '\b',
15
+ "\t" => '\t',
16
+ "\n" => '\n',
17
+ "\xb" => '\u000b',
18
+ "\f" => '\f',
19
+ "\r" => '\r',
20
+ "\xe" => '\u000e',
21
+ "\xf" => '\u000f',
22
+ "\x10" => '\u0010',
23
+ "\x11" => '\u0011',
24
+ "\x12" => '\u0012',
25
+ "\x13" => '\u0013',
26
+ "\x14" => '\u0014',
27
+ "\x15" => '\u0015',
28
+ "\x16" => '\u0016',
29
+ "\x17" => '\u0017',
30
+ "\x18" => '\u0018',
31
+ "\x19" => '\u0019',
32
+ "\x1a" => '\u001a',
33
+ "\x1b" => '\u001b',
34
+ "\x1c" => '\u001c',
35
+ "\x1d" => '\u001d',
36
+ "\x1e" => '\u001e',
37
+ "\x1f" => '\u001f',
38
+ '"' => '\"',
39
+ '\\' => '\\\\',
40
+ }.freeze # :nodoc:
41
+
42
+ ESCAPE_PATTERN = /[\/"\\\x0-\x1f]/n # :nodoc:
43
+
44
+ SCRIPT_SAFE_MAP = MAP.merge(
45
+ '/' => '\\/',
46
+ "\u2028".b => '\u2028',
47
+ "\u2029".b => '\u2029',
48
+ ).freeze
49
+
50
+ SCRIPT_SAFE_ESCAPE_PATTERN = Regexp.union(ESCAPE_PATTERN, "\u2028".b, "\u2029".b)
51
+
52
+ # Convert a UTF8 encoded Ruby string _string_ to a JSON string, encoded with
53
+ # UTF16 big endian characters as \u????, and return it.
54
+ def utf8_to_json(string, script_safe = false) # :nodoc:
55
+ string = string.b
56
+ if script_safe
57
+ string.gsub!(SCRIPT_SAFE_ESCAPE_PATTERN) { SCRIPT_SAFE_MAP[$&] || $& }
58
+ else
59
+ string.gsub!(ESCAPE_PATTERN) { MAP[$&] || $& }
60
+ end
61
+ string.force_encoding(::Encoding::UTF_8)
62
+ string
63
+ end
62
64
 
63
- def utf8_to_json_ascii(string, script_safe = false) # :nodoc:
64
- string = string.b
65
- map = script_safe ? SCRIPT_SAFE_MAP : MAP
66
- string.gsub!(/[\/"\\\x0-\x1f]/n) { map[$&] || $& }
67
- string.gsub!(/(
68
- (?:
69
- [\xc2-\xdf][\x80-\xbf] |
70
- [\xe0-\xef][\x80-\xbf]{2} |
71
- [\xf0-\xf4][\x80-\xbf]{3}
72
- )+ |
73
- [\x80-\xc1\xf5-\xff] # invalid
74
- )/nx) { |c|
75
- c.size == 1 and raise GeneratorError, "invalid utf8 byte: '#{c}'"
76
- s = c.encode(::Encoding::UTF_16BE, ::Encoding::UTF_8).unpack('H*')[0]
77
- s.force_encoding(::Encoding::ASCII_8BIT)
78
- s.gsub!(/.{4}/n, '\\\\u\&')
79
- s.force_encoding(::Encoding::UTF_8)
80
- }
81
- string.force_encoding(::Encoding::UTF_8)
82
- string
83
- rescue => e
84
- raise GeneratorError.wrap(e)
85
- end
65
+ def utf8_to_json_ascii(original_string, script_safe = false) # :nodoc:
66
+ string = original_string.b
67
+ map = script_safe ? SCRIPT_SAFE_MAP : MAP
68
+ string.gsub!(/[\/"\\\x0-\x1f]/n) { map[$&] || $& }
69
+ string.gsub!(/(
70
+ (?:
71
+ [\xc2-\xdf][\x80-\xbf] |
72
+ [\xe0-\xef][\x80-\xbf]{2} |
73
+ [\xf0-\xf4][\x80-\xbf]{3}
74
+ )+ |
75
+ [\x80-\xc1\xf5-\xff] # invalid
76
+ )/nx) { |c|
77
+ c.size == 1 and raise GeneratorError.new("invalid utf8 byte: '#{c}'", original_string)
78
+ s = c.encode(::Encoding::UTF_16BE, ::Encoding::UTF_8).unpack('H*')[0]
79
+ s.force_encoding(::Encoding::BINARY)
80
+ s.gsub!(/.{4}/n, '\\\\u\&')
81
+ s.force_encoding(::Encoding::UTF_8)
82
+ }
83
+ string.force_encoding(::Encoding::UTF_8)
84
+ string
85
+ rescue => e
86
+ raise GeneratorError.new(e.message, original_string)
87
+ end
86
88
 
87
- def valid_utf8?(string)
88
- encoding = string.encoding
89
- (encoding == Encoding::UTF_8 || encoding == Encoding::ASCII) &&
90
- string.valid_encoding?
91
- end
92
- module_function :utf8_to_json, :utf8_to_json_ascii, :valid_utf8?
89
+ def valid_utf8?(string)
90
+ encoding = string.encoding
91
+ (encoding == Encoding::UTF_8 || encoding == Encoding::ASCII) &&
92
+ string.valid_encoding?
93
+ end
94
+ module_function :utf8_to_json, :utf8_to_json_ascii, :valid_utf8?
93
95
 
94
- module Pure
95
- module Generator
96
96
  # This class is used to create State instances, that are use to hold data
97
97
  # while generating a JSON text from a Ruby data structure.
98
98
  class State
99
+ def self.generate(obj, opts = nil, io = nil)
100
+ string = new(opts).generate(obj)
101
+ if io
102
+ io.write(string)
103
+ io
104
+ else
105
+ string
106
+ end
107
+ end
108
+
99
109
  # Creates a State object from _opts_, which ought to be Hash to create
100
110
  # a new State instance configured by _opts_, something else to create
101
111
  # an unconfigured instance. If _opts_ is a State object, it is just
@@ -130,7 +140,7 @@ module JSON
130
140
  # * *allow_nan*: true if NaN, Infinity, and -Infinity should be
131
141
  # generated, otherwise an exception is thrown, if these values are
132
142
  # encountered. This options defaults to false.
133
- def initialize(opts = {})
143
+ def initialize(opts = nil)
134
144
  @indent = ''
135
145
  @space = ''
136
146
  @space_before = ''
@@ -138,10 +148,12 @@ module JSON
138
148
  @array_nl = ''
139
149
  @allow_nan = false
140
150
  @ascii_only = false
141
- @script_safe = false
142
- @strict = false
151
+ @depth = 0
143
152
  @buffer_initial_length = 1024
144
- configure opts
153
+ @script_safe = false
154
+ @strict = false
155
+ @max_nesting = 100
156
+ configure(opts) if opts
145
157
  end
146
158
 
147
159
  # This string is used to indent levels in the JSON text.
@@ -294,8 +306,10 @@ module JSON
294
306
  else
295
307
  result = obj.to_json(self)
296
308
  end
297
- JSON.valid_utf8?(result) or raise GeneratorError,
298
- "source sequence #{result.inspect} is illegal/malformed utf-8"
309
+ JSON::TruffleRuby::Generator.valid_utf8?(result) or raise GeneratorError.new(
310
+ "source sequence #{result.inspect} is illegal/malformed utf-8",
311
+ obj
312
+ )
299
313
  result
300
314
  end
301
315
 
@@ -307,7 +321,16 @@ module JSON
307
321
  first = true
308
322
  obj.each_pair do |k,v|
309
323
  buf << ',' unless first
310
- fast_serialize_string(k.to_s, buf)
324
+
325
+ key_str = k.to_s
326
+ if key_str.class == String
327
+ fast_serialize_string(key_str, buf)
328
+ elsif key_str.is_a?(String)
329
+ generate_json(key_str, buf)
330
+ else
331
+ raise TypeError, "#{k.class}#to_s returns an instance of #{key_str.class}, expected a String"
332
+ end
333
+
311
334
  buf << ':'
312
335
  generate_json(v, buf)
313
336
  first = false
@@ -323,7 +346,11 @@ module JSON
323
346
  end
324
347
  buf << ']'
325
348
  when String
326
- fast_serialize_string(obj, buf)
349
+ if obj.class == String
350
+ fast_serialize_string(obj, buf)
351
+ else
352
+ buf << obj.to_json(self)
353
+ end
327
354
  when Integer
328
355
  buf << obj.to_s
329
356
  else
@@ -333,24 +360,23 @@ module JSON
333
360
  end
334
361
 
335
362
  # Assumes !@ascii_only, !@script_safe
336
- if Regexp.method_defined?(:match?)
337
- private def fast_serialize_string(string, buf) # :nodoc:
338
- buf << '"'
339
- string = string.encode(::Encoding::UTF_8) unless string.encoding == ::Encoding::UTF_8
340
- raise GeneratorError, "source sequence is illegal/malformed utf-8" unless string.valid_encoding?
341
-
342
- if /["\\\x0-\x1f]/n.match?(string)
343
- buf << string.gsub(/["\\\x0-\x1f]/n, MAP)
344
- else
345
- buf << string
363
+ private def fast_serialize_string(string, buf) # :nodoc:
364
+ buf << '"'
365
+ unless string.encoding == ::Encoding::UTF_8
366
+ begin
367
+ string = string.encode(::Encoding::UTF_8)
368
+ rescue Encoding::UndefinedConversionError => error
369
+ raise GeneratorError.new(error.message, string)
346
370
  end
347
- buf << '"'
348
371
  end
349
- else
350
- # Ruby 2.3 compatibility
351
- private def fast_serialize_string(string, buf) # :nodoc:
352
- buf << string.to_json(self)
372
+ raise GeneratorError.new("source sequence is illegal/malformed utf-8", string) unless string.valid_encoding?
373
+
374
+ if /["\\\x0-\x1f]/n.match?(string)
375
+ buf << string.gsub(/["\\\x0-\x1f]/n, MAP)
376
+ else
377
+ buf << string
353
378
  end
379
+ buf << '"'
354
380
  end
355
381
 
356
382
  # Return the value returned by method +name+.
@@ -379,7 +405,7 @@ module JSON
379
405
  # special method #to_json was defined for some object.
380
406
  def to_json(state = nil, *)
381
407
  if state && State.from_state(state).strict?
382
- raise GeneratorError, "#{self.class} not allowed in JSON"
408
+ raise GeneratorError.new("#{self.class} not allowed in JSON", self)
383
409
  else
384
410
  to_s.to_json
385
411
  end
@@ -406,17 +432,31 @@ module JSON
406
432
  end
407
433
 
408
434
  def json_transform(state)
435
+ depth = state.depth += 1
436
+
437
+ if empty?
438
+ state.depth -= 1
439
+ return '{}'
440
+ end
441
+
409
442
  delim = ",#{state.object_nl}"
410
443
  result = +"{#{state.object_nl}"
411
- depth = state.depth += 1
412
444
  first = true
413
445
  indent = !state.object_nl.empty?
414
446
  each { |key, value|
415
447
  result << delim unless first
416
448
  result << state.indent * depth if indent
417
- result = +"#{result}#{key.to_s.to_json(state)}#{state.space_before}:#{state.space}"
449
+
450
+ key_str = key.to_s
451
+ if key_str.is_a?(String)
452
+ key_json = key_str.to_json(state)
453
+ else
454
+ raise TypeError, "#{key.class}#to_s returns an instance of #{key_str.class}, expected a String"
455
+ end
456
+
457
+ result = +"#{result}#{key_json}#{state.space_before}:#{state.space}"
418
458
  if state.strict? && !(false == value || true == value || nil == value || String === value || Array === value || Hash === value || Integer === value || Float === value)
419
- raise GeneratorError, "#{value.class} not allowed in JSON"
459
+ raise GeneratorError.new("#{value.class} not allowed in JSON", value)
420
460
  elsif value.respond_to?(:to_json)
421
461
  result << value.to_json(state)
422
462
  else
@@ -448,6 +488,13 @@ module JSON
448
488
  private
449
489
 
450
490
  def json_transform(state)
491
+ depth = state.depth += 1
492
+
493
+ if empty?
494
+ state.depth -= 1
495
+ return '[]'
496
+ end
497
+
451
498
  result = '['.dup
452
499
  if state.array_nl.empty?
453
500
  delim = ","
@@ -455,14 +502,14 @@ module JSON
455
502
  result << state.array_nl
456
503
  delim = ",#{state.array_nl}"
457
504
  end
458
- depth = state.depth += 1
505
+
459
506
  first = true
460
507
  indent = !state.array_nl.empty?
461
508
  each { |value|
462
509
  result << delim unless first
463
510
  result << state.indent * depth if indent
464
511
  if state.strict? && !(false == value || true == value || nil == value || String === value || Array === value || Hash === value || Integer === value || Float === value)
465
- raise GeneratorError, "#{value.class} not allowed in JSON"
512
+ raise GeneratorError.new("#{value.class} not allowed in JSON", value)
466
513
  elsif value.respond_to?(:to_json)
467
514
  result << value.to_json(state)
468
515
  else
@@ -491,13 +538,13 @@ module JSON
491
538
  if state.allow_nan?
492
539
  to_s
493
540
  else
494
- raise GeneratorError, "#{self} not allowed in JSON"
541
+ raise GeneratorError.new("#{self} not allowed in JSON", self)
495
542
  end
496
543
  when nan?
497
544
  if state.allow_nan?
498
545
  to_s
499
546
  else
500
- raise GeneratorError, "#{self} not allowed in JSON"
547
+ raise GeneratorError.new("#{self} not allowed in JSON", self)
501
548
  end
502
549
  else
503
550
  to_s
@@ -513,17 +560,19 @@ module JSON
513
560
  state = State.from_state(state)
514
561
  if encoding == ::Encoding::UTF_8
515
562
  unless valid_encoding?
516
- raise GeneratorError, "source sequence is illegal/malformed utf-8"
563
+ raise GeneratorError.new("source sequence is illegal/malformed utf-8", self)
517
564
  end
518
565
  string = self
519
566
  else
520
567
  string = encode(::Encoding::UTF_8)
521
568
  end
522
569
  if state.ascii_only?
523
- %("#{JSON.utf8_to_json_ascii(string, state.script_safe)}")
570
+ %("#{JSON::TruffleRuby::Generator.utf8_to_json_ascii(string, state.script_safe)}")
524
571
  else
525
- %("#{JSON.utf8_to_json(string, state.script_safe)}")
572
+ %("#{JSON::TruffleRuby::Generator.utf8_to_json(string, state.script_safe)}")
526
573
  end
574
+ rescue Encoding::UndefinedConversionError => error
575
+ raise ::JSON::GeneratorError.new(error.message, self)
527
576
  end
528
577
 
529
578
  # Module that holds the extending methods if, the String module is
data/lib/json/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module JSON
4
- VERSION = '2.7.5'
4
+ VERSION = '2.9.1'
5
5
  end
data/lib/json.rb CHANGED
@@ -378,13 +378,13 @@ require 'json/common'
378
378
  # json1 = JSON.generate(ruby)
379
379
  # ruby1 = JSON.parse(json1, create_additions: true)
380
380
  # # Make a nice display.
381
- # display = <<EOT
382
- # Generated JSON:
383
- # Without addition: #{json0} (#{json0.class})
384
- # With addition: #{json1} (#{json1.class})
385
- # Parsed JSON:
386
- # Without addition: #{ruby0.inspect} (#{ruby0.class})
387
- # With addition: #{ruby1.inspect} (#{ruby1.class})
381
+ # display = <<~EOT
382
+ # Generated JSON:
383
+ # Without addition: #{json0} (#{json0.class})
384
+ # With addition: #{json1} (#{json1.class})
385
+ # Parsed JSON:
386
+ # Without addition: #{ruby0.inspect} (#{ruby0.class})
387
+ # With addition: #{ruby1.inspect} (#{ruby1.class})
388
388
  # EOT
389
389
  # puts display
390
390
  #
@@ -562,13 +562,13 @@ require 'json/common'
562
562
  # json1 = JSON.generate(foo1)
563
563
  # obj1 = JSON.parse(json1, create_additions: true)
564
564
  # # Make a nice display.
565
- # display = <<EOT
566
- # Generated JSON:
567
- # Without custom addition: #{json0} (#{json0.class})
568
- # With custom addition: #{json1} (#{json1.class})
569
- # Parsed JSON:
570
- # Without custom addition: #{obj0.inspect} (#{obj0.class})
571
- # With custom addition: #{obj1.inspect} (#{obj1.class})
565
+ # display = <<~EOT
566
+ # Generated JSON:
567
+ # Without custom addition: #{json0} (#{json0.class})
568
+ # With custom addition: #{json1} (#{json1.class})
569
+ # Parsed JSON:
570
+ # Without custom addition: #{obj0.inspect} (#{obj0.class})
571
+ # With custom addition: #{obj1.inspect} (#{obj1.class})
572
572
  # EOT
573
573
  # puts display
574
574
  #
@@ -583,10 +583,5 @@ require 'json/common'
583
583
  #
584
584
  module JSON
585
585
  require 'json/version'
586
-
587
- begin
588
- require 'json/ext'
589
- rescue LoadError
590
- require 'json/pure'
591
- end
586
+ require 'json/ext'
592
587
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: json
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.5
4
+ version: 2.9.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-10-30 00:00:00.000000000 Z
11
+ date: 2024-12-18 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: This is a JSON implementation as a Ruby extension in C.
14
14
  email: flori@ping.de
@@ -27,10 +27,8 @@ files:
27
27
  - ext/json/ext/fbuffer/fbuffer.h
28
28
  - ext/json/ext/generator/extconf.rb
29
29
  - ext/json/ext/generator/generator.c
30
- - ext/json/ext/generator/generator.h
31
30
  - ext/json/ext/parser/extconf.rb
32
31
  - ext/json/ext/parser/parser.c
33
- - ext/json/ext/parser/parser.h
34
32
  - ext/json/ext/parser/parser.rl
35
33
  - json.gemspec
36
34
  - lib/json.rb
@@ -52,9 +50,7 @@ files:
52
50
  - lib/json/ext.rb
53
51
  - lib/json/ext/generator/state.rb
54
52
  - lib/json/generic_object.rb
55
- - lib/json/pure.rb
56
- - lib/json/pure/generator.rb
57
- - lib/json/pure/parser.rb
53
+ - lib/json/truffle_ruby/generator.rb
58
54
  - lib/json/version.rb
59
55
  homepage: https://ruby.github.io/json
60
56
  licenses:
@@ -78,7 +74,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
78
74
  requirements:
79
75
  - - ">="
80
76
  - !ruby/object:Gem::Version
81
- version: '2.3'
77
+ version: '2.7'
82
78
  required_rubygems_version: !ruby/object:Gem::Requirement
83
79
  requirements:
84
80
  - - ">="
@@ -1,118 +0,0 @@
1
- #ifndef _GENERATOR_H_
2
- #define _GENERATOR_H_
3
-
4
- #include <math.h>
5
- #include <ctype.h>
6
-
7
- #include "ruby.h"
8
-
9
- /* This is the fallback definition from Ruby 3.4 */
10
- #ifndef RBIMPL_STDBOOL_H
11
- #if defined(__cplusplus)
12
- # if defined(HAVE_STDBOOL_H) && (__cplusplus >= 201103L)
13
- # include <cstdbool>
14
- # endif
15
- #elif defined(HAVE_STDBOOL_H)
16
- # include <stdbool.h>
17
- #elif !defined(HAVE__BOOL)
18
- typedef unsigned char _Bool;
19
- # define bool _Bool
20
- # define true ((_Bool)+1)
21
- # define false ((_Bool)+0)
22
- # define __bool_true_false_are_defined
23
- #endif
24
- #endif
25
-
26
- static char *fstrndup(const char *ptr, unsigned long len);
27
-
28
- /* ruby api and some helpers */
29
-
30
- typedef struct JSON_Generator_StateStruct {
31
- char *indent;
32
- long indent_len;
33
- char *space;
34
- long space_len;
35
- char *space_before;
36
- long space_before_len;
37
- char *object_nl;
38
- long object_nl_len;
39
- char *array_nl;
40
- long array_nl_len;
41
- long max_nesting;
42
- char allow_nan;
43
- char ascii_only;
44
- char script_safe;
45
- char strict;
46
- long depth;
47
- long buffer_initial_length;
48
- } JSON_Generator_State;
49
-
50
- #define GET_STATE_TO(self, state) \
51
- TypedData_Get_Struct(self, JSON_Generator_State, &JSON_Generator_State_type, state)
52
-
53
- #define GET_STATE(self) \
54
- JSON_Generator_State *state; \
55
- GET_STATE_TO(self, state)
56
-
57
-
58
- static VALUE mHash_to_json(int argc, VALUE *argv, VALUE self);
59
- static VALUE mArray_to_json(int argc, VALUE *argv, VALUE self);
60
- #ifdef RUBY_INTEGER_UNIFICATION
61
- static VALUE mInteger_to_json(int argc, VALUE *argv, VALUE self);
62
- #else
63
- static VALUE mFixnum_to_json(int argc, VALUE *argv, VALUE self);
64
- static VALUE mBignum_to_json(int argc, VALUE *argv, VALUE self);
65
- #endif
66
- static VALUE mFloat_to_json(int argc, VALUE *argv, VALUE self);
67
- static VALUE mString_included_s(VALUE self, VALUE modul);
68
- static VALUE mString_to_json(int argc, VALUE *argv, VALUE self);
69
- static VALUE mString_to_json_raw_object(VALUE self);
70
- static VALUE mString_to_json_raw(int argc, VALUE *argv, VALUE self);
71
- static VALUE mString_Extend_json_create(VALUE self, VALUE o);
72
- static VALUE mTrueClass_to_json(int argc, VALUE *argv, VALUE self);
73
- static VALUE mFalseClass_to_json(int argc, VALUE *argv, VALUE self);
74
- static VALUE mNilClass_to_json(int argc, VALUE *argv, VALUE self);
75
- static VALUE mObject_to_json(int argc, VALUE *argv, VALUE self);
76
- static void State_free(void *state);
77
- static VALUE cState_s_allocate(VALUE klass);
78
- static void generate_json(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
79
- static void generate_json_object(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
80
- static void generate_json_array(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
81
- static void generate_json_string(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
82
- static void generate_json_null(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
83
- static void generate_json_false(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
84
- static void generate_json_true(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
85
- #ifdef RUBY_INTEGER_UNIFICATION
86
- static void generate_json_integer(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
87
- #endif
88
- static void generate_json_fixnum(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
89
- static void generate_json_bignum(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
90
- static void generate_json_float(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj);
91
- static VALUE cState_partial_generate(VALUE self, VALUE obj, void (*func)(FBuffer *buffer, VALUE Vstate, JSON_Generator_State *state, VALUE obj));
92
- static VALUE cState_generate(VALUE self, VALUE obj);
93
- static VALUE cState_from_state_s(VALUE self, VALUE opts);
94
- static VALUE cState_indent(VALUE self);
95
- static VALUE cState_indent_set(VALUE self, VALUE indent);
96
- static VALUE cState_space(VALUE self);
97
- static VALUE cState_space_set(VALUE self, VALUE space);
98
- static VALUE cState_space_before(VALUE self);
99
- static VALUE cState_space_before_set(VALUE self, VALUE space_before);
100
- static VALUE cState_object_nl(VALUE self);
101
- static VALUE cState_object_nl_set(VALUE self, VALUE object_nl);
102
- static VALUE cState_array_nl(VALUE self);
103
- static VALUE cState_array_nl_set(VALUE self, VALUE array_nl);
104
- static VALUE cState_max_nesting(VALUE self);
105
- static VALUE cState_max_nesting_set(VALUE self, VALUE depth);
106
- static VALUE cState_allow_nan_p(VALUE self);
107
- static VALUE cState_ascii_only_p(VALUE self);
108
- static VALUE cState_depth(VALUE self);
109
- static VALUE cState_depth_set(VALUE self, VALUE depth);
110
- static VALUE cState_script_safe(VALUE self);
111
- static VALUE cState_script_safe_set(VALUE self, VALUE depth);
112
- static VALUE cState_strict(VALUE self);
113
- static VALUE cState_strict_set(VALUE self, VALUE strict);
114
- static FBuffer *cState_prepare_buffer(VALUE self);
115
-
116
- static const rb_data_type_t JSON_Generator_State_type;
117
-
118
- #endif