# File lib/json/pure/generator.rb, line 237
237:           def to_json(state = nil, depth = 0, *)
238:             if state
239:               state = JSON.state.from_state(state)
240:               state.check_max_nesting(depth)
241:               json_check_circular(state) { json_transform(state, depth) }
242:             else
243:               json_transform(state, depth)
244:             end
245:           end