summaryrefslogtreecommitdiff
path: root/lib/json/pure/generator.rb
diff options
context:
space:
mode:
authorTim Felgentreff <timfelgentreff@gmail.com>2011-12-09 11:46:01 +0100
committerTim Felgentreff <timfelgentreff@gmail.com>2011-12-09 11:46:01 +0100
commit59ecfad89281873fe72234b62545294b5fa7ba95 (patch)
treeba73bea0660d74b2a9a787c5e0acd1a06739e1b6 /lib/json/pure/generator.rb
parente3784346b6524d2350baa2da2845377557d840ec (diff)
parente7927d3f04973d8ed1618215c3750aebf80681d4 (diff)
downloadjson-59ecfad89281873fe72234b62545294b5fa7ba95.tar.gz
Merge remote-tracking branch 'json/master'
Conflicts: ext/json/ext/parser/parser.c ext/json/ext/parser/parser.rl
Diffstat (limited to 'lib/json/pure/generator.rb')
-rw-r--r--lib/json/pure/generator.rb29
1 files changed, 20 insertions, 9 deletions
diff --git a/lib/json/pure/generator.rb b/lib/json/pure/generator.rb
index 7c9b2ad..9141ae5 100644
--- a/lib/json/pure/generator.rb
+++ b/lib/json/pure/generator.rb
@@ -136,14 +136,15 @@ module JSON
# * *quirks_mode*: Enables quirks_mode for parser, that is for example
# generating single JSON values instead of documents is possible.
def initialize(opts = {})
- @indent = ''
- @space = ''
- @space_before = ''
- @object_nl = ''
- @array_nl = ''
- @allow_nan = false
- @ascii_only = false
- @quirks_mode = false
+ @indent = ''
+ @space = ''
+ @space_before = ''
+ @object_nl = ''
+ @array_nl = ''
+ @allow_nan = false
+ @ascii_only = false
+ @quirks_mode = false
+ @buffer_initial_length = 1024
configure opts
end
@@ -172,6 +173,16 @@ module JSON
# it's disabled.
attr_accessor :quirks_mode
+ # :stopdoc:
+ attr_reader :buffer_initial_length
+
+ def buffer_initial_length=(length)
+ if length > 0
+ @buffer_initial_length = length
+ end
+ end
+ # :startdoc:
+
# This integer returns the current depth data structure nesting in the
# generated JSON.
attr_accessor :depth
@@ -233,7 +244,7 @@ module JSON
# passed to the configure method.
def to_h
result = {}
- for iv in %w[indent space space_before object_nl array_nl allow_nan max_nesting ascii_only quirks_mode depth]
+ for iv in %w[indent space space_before object_nl array_nl allow_nan max_nesting ascii_only quirks_mode buffer_initial_length depth]
result[iv.intern] = instance_variable_get("@#{iv}")
end
result