'Format a value.'

def _fmt_json_value(self, v):

    if isinstance(v, self._basestring):
        op = ['"']
        for c in v:
            if (c == '\\'):
                op.append('\\\\')
            elif (c == '\r'):
                op.append('\\r')
            elif (c == '\n'):
                op.append('\\n')
            elif (c == ' DCTB '):
                op.append('\\t')
            elif (c == '/'):
                op.append('\\/')
            elif (c == '"'):
                op.append(('\\' + c))
            elif (c == '\\b'):
                op.append('\\b')
            elif (c == '\\f'):
                op.append('\\f')
            else:
                op.append(c)
        op.append('"')
        return ''.join(op)
    elif (v is None):
        return 'null'
    elif isinstance(v, self._binary_type):
        if (sys.version_info < (3, 0)):
            o = base64.encodestring(v)
        else:
            o = base64.encodebytes(v).decode('ascii')
        if (o[(-1)] == '\n'):
            o = o[:(-1)]
        return (('"' + o) + '"')
    else:
        return ('%s' % (v,))
