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 332 332: def to_json(state = nil, *) 333: state = State.from_state(state) 334: state.check_max_nesting 335: json_transform(state) 336: end
# File lib/json/pure/generator.rb, line 340 340: def json_transform(state) 341: delim = ',' 342: delim << state.array_nl 343: result = '[' 344: result << state.array_nl 345: depth = state.depth += 1 346: first = true 347: indent = !state.array_nl.empty? 348: each { |value| 349: result << delim unless first 350: result << state.indent * depth if indent 351: result << value.to_json(state) 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
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.