# File lib/json/common.rb, line 281
281:   def dump(obj, anIO = nil, limit = nil)
282:     if anIO and limit.nil?
283:       anIO = anIO.to_io if anIO.respond_to?(:to_io)
284:       unless anIO.respond_to?(:write)
285:         limit = anIO
286:         anIO = nil
287:       end
288:     end
289:     limit ||= 0
290:     result = generate(obj, :allow_nan => true, :max_nesting => limit)
291:     if anIO
292:       anIO.write result
293:       anIO
294:     else
295:       result
296:     end
297:   rescue JSON::NestingError
298:     raise ArgumentError, "exceed depth limit"
299:   end