def internal_evaluate_expression_json(py_db, request, thread_id):
    '''
    :param EvaluateRequest request:
    '''
    # : :type arguments: EvaluateArguments

    arguments = request.arguments
    expression = arguments.expression
    frame_id = arguments.frameId
    context = arguments.context
    fmt = arguments.format
    if hasattr(fmt, 'to_dict'):
        fmt = fmt.to_dict()

    if IS_PY2 and isinstance(expression, unicode):
        try:
            expression = expression.encode('utf-8')
        except:
            _evaluate_response(py_db, request, '', error_message='Expression is not valid utf-8.')
            raise

    frame = py_db.find_frame(thread_id, frame_id)
    result = pydevd_vars.evaluate_expression(py_db, frame, expression, is_exec=False)
    is_error = isinstance(result, ExceptionOnEvaluate)

    if is_error:
        if context == 'hover':
            _evaluate_response(py_db, request, result='')
            return

        elif context == 'repl':
            try:
                pydevd_vars.evaluate_expression(py_db, frame, expression, is_exec=True)
            except Exception as ex:
                err = ''.join(traceback.format_exception_only(type(ex), ex))
                _evaluate_response(py_db, request, result='', error_message=err)
                return
            # No result on exec.
            _evaluate_response(py_db, request, result='')
            return

    # Ok, we have the result (could be an error), let's put it into the saved variables.
    frame_tracker = py_db.suspended_frames_manager.get_frame_tracker(thread_id)
    if frame_tracker is None:
        # This is not really expected.
        _evaluate_response(py_db, request, result, error_message='Thread id: %s is not current thread id.' % (thread_id,))
        return

    variable = frame_tracker.obtain_as_variable(expression, result)
    var_data = variable.get_var_data(fmt=fmt)

    body = pydevd_schema.EvaluateResponseBody(
        result=var_data['value'],
        variablesReference=var_data.get('variablesReference', 0),
        type=var_data.get('type'),
        presentationHint=var_data.get('presentationHint'),
        namedVariables=var_data.get('namedVariables'),
        indexedVariables=var_data.get('indexedVariables'),
    )
    variables_response = pydevd_base_schema.build_response(request, kwargs={'body':body})
    py_db.writer.add_command(NetCommand(CMD_RETURN, 0, variables_response, is_json=True))
:param EvaluateRequest request: