# File lib/json/common.rb, line 291 291: def dump(obj, anIO = nil, limit = nil) 292: if anIO and limit.nil? 293: anIO = anIO.to_io if anIO.respond_to?(:to_io) 294: unless anIO.respond_to?(:write) 295: limit = anIO 296: anIO = nil 297: end 298: end 299: limit ||= 0 300: result = generate(obj, :allow_nan => true, :max_nesting => limit) 301: if anIO 302: anIO.write result 303: anIO 304: else 305: result 306: end 307: rescue JSON::NestingError 308: raise ArgumentError, "exceed depth limit" 309: end