# File lib/json/pure/generator.rb, line 241
          def to_json(state = nil, depth = 0, *)
            if state
              state = JSON.state.from_state(state)
              state.check_max_nesting(depth)
              json_check_circular(state) { json_transform(state, depth) }
            else
              json_transform(state, depth)
            end
          end