Returns a JSON string containing a JSON array, that is unparsed from this Array instance. state is a JSON::State object, that can also be used to configure the produced JSON string output further.
# File lib/json/pure/generator.rb, line 299 299: def to_json(state = nil, *) 300: state = State.from_state(state) 301: state.check_max_nesting 302: json_transform(state) 303: end
# File lib/json/pure/generator.rb, line 307 307: def json_transform(state) 308: delim = ',' 309: delim << state.array_nl 310: result = '[' 311: result << state.array_nl 312: depth = state.depth += 1 313: first = true 314: indent = !state.array_nl.empty? 315: each { |value| 316: result << delim unless first 317: result << state.indent * depth if indent 318: result << value.to_json(state) 319: first = false 320: } 321: depth = state.depth -= 1 322: result << state.array_nl 323: result << state.indent * depth if indent 324: result << ']' 325: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.