    # File lib/json/pure/generator.rb, line 390
                def to_json(state = nil, *args)
                  state = State.from_state(state)
                  if encoding == ::Encoding::UTF_8
                    string = self
                  else
                    string = encode(::Encoding::UTF_8)
                  end
                  if state.ascii_only?
                    '"' << JSON.utf8_to_json_ascii(string) << '"'
                  else
                    '"' << JSON.utf8_to_json(string) << '"'
                  end
                end