当前位置: 代码迷 >> python >> 当我转储错误的json时,将json发送到弹性搜索时出错
  详细解决方案

当我转储错误的json时,将json发送到弹性搜索时出错

热度:72   发布时间:2023-06-13 13:58:29.0

我通过将josn发送到弹性搜索将数据上传到弹性搜索服务器,它工作正常,但在某些字符上,例如\\它给出错误,当我在json中发送反斜杠时&&如果我转储响应的json,它将给出错误

"{"error": {"caused_by": {"reason": "Compressor detection can only be called on some xcontent bytes or compressed xcontent bytes", "type": "not_x_content_exception"}, "reason": "failed to parse", "root_cause": [{"reason": "failed to parse", "type": "mapper_parsing_exception"}], "type": "mapper_parsing_exception"}, "status": 400}"

我的jon字符串是

"{

"first_name":"muhammad irfan",

"middle_name": "",

"last_name":"ulhaq choudhary",

"address":"H,no,197,St,no. 157. G-9\\4",

"city":"Islamabad",

"phone_number1":"",

"phone_number2":"",

"phone_number3":"",

"gender":"M",

"updation_time":"0000-01-01",

"country_id":"1"
}
"

我不知道您使用哪个包裹。 但是您可以尝试使用\\\\\\\\代替\\\\

  相关解决方案