SOURCE

const res = "{'config_change': True, 'refresh_page': False, 'attack_detail': {'msg': 'Host header is a numeric IP address', 'detail': 'Attack/violation with pending signature recorded. Matched \"Operator `Rx\\' with parameter `^(?:[\\\\d.]+|\\\\[[\\\\dA-Fa-f.:]+\\\\])(?::\\\\d+)?$\\' against variable `REQUEST_HEADERS:HOST\\' (Value: `1.2.3.4\\' )'}, 'request_body': u'', 'response_body': u'', 'msg': '', 'response_header': 'HTTP/1.1 200\\nServer: nginx/1.4.6 (Ubuntu)\\nDate: Sat, 17 Sep 2022 03:15:00 GMT\\nContent-Type: text/html\\nContent-Length: 621\\nLast-Modified: Mon, 27 Jun 2022 09:22:09 GMT\\nConnection: keep-alive\\nETag: \"62b976c1-26d\"\\nAccept-Ranges: bytes\\n', 'request_header': 'GET / HTTP/1.1\\nHOST: 1.2.3.4\\n'}"

const resArr = res.split(',')
// console.log(resArr)

const obj = {}

resArr.forEach((v) => {
    // 清除单引号(')、头尾的花括号({})、空格
    const str = v.replace(/\'/g, '').replace(/\{/g, '').replace(/\}/g, ''.replace(/\s+/g, ''))
    // console.log(str)

    const arr = str.split(':')
    obj[arr[0]] = arr[1]
})

console.log(obj)
console 命令行工具 X clear

                    
>
console