my environment is nodejs
let z = await x.text();
console.log(z)
let y = JSON.parse(z)
the console log is
{
"errorCode":0,
"errorMsg":"success",
"result":{
"msg":"\u4e70\u5bb6\u5df2",
"uid":"104",
"username":"\u738b\u626d",
"userphone":"1565777778",
"address":"\u4e0a\u6d77",
"price":"5.00",
"trade_state":"TRADE_SUCCESS",
"hk_orderid":"1575524694820"
}
}
(node:21) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token in JSON at position 0
when I copy the json string and paste it to
JSON.parse('{"errorCode":0,"errorMsg":"success","result":{"msg":"\u4e70\u5bb6\u5df2","uid":"104","username":"\u738b\u626d","userphone":"1565777778","address":"\u4e0a\u6d77","price":"5.00","trade_state":"TRADE_SUCCESS","hk_orderid":"1575524694820"}}')
inside browser console
the parsing is correct
edit: someone asks about the json, actually the json is exactly what I pasted above
{
"errorCode":0,
"errorMsg":"success",
"result":{
"msg":"\u4e70\u5bb6\u5df2",
"uid":"104",
"username":"\u738b\u626d",
"userphone":"1565777778",
"address":"\u4e0a\u6d77",
"price":"5.00",
"trade_state":"TRADE_SUCCESS",
"hk_orderid":"1575524694820"
}
}
this is also the output of console.log(z)
below are some further logs, note that only the last one has an exception
processing job id 19121211173822287103
12/12/2019 12:17:45 PM {"errorCode":0,"errorMsg":"success","result":{"msg":"\u7b49\u5f85\u8cb7\u5bb6\u4ed8\u6b3e","uid":"103","username":"\u674e\u767d","userphone":"18912345678","address":"\u7ef4\u4e5f\u7eb3\u9152\u5e97(\u77f3\u82b1\u897f\u8def\u5e97)","price":"4.00","trade_state":"WAIT_BUYER_PAY","hk_orderid":"1576120657890"}}
12/12/2019 12:17:50 PM processing job id 19121211173822287103
12/12/2019 12:17:50 PM {"errorCode":0,"errorMsg":"success","result":{"msg":"\u7b49\u5f85\u8cb7\u5bb6\u4ed8\u6b3e","uid":"103","username":"\u674e\u767d","userphone":"18912345678","address":"\u7ef4\u4e5f\u7eb3\u9152\u5e97(\u77f3\u82b1\u897f\u8def\u5e97)","price":"4.00","trade_state":"WAIT_BUYER_PAY","hk_orderid":"1576120657890"}}
12/12/2019 12:17:55 PM processing job id 19121211173822287103
12/12/2019 12:17:57 PM
12/12/2019 12:17:57 PM {"errorCode":0,"errorMsg":"success","result":{"msg":"\u4e70\u5bb6\u5df2\u652f\u4ed8","uid":"103","username":"\u674e\u767d","userphone":"18912345678","address":"\u7ef4\u4e5f\u7eb3\u9152\u5e97(\u77f3\u82b1\u897f\u8def\u5e97)","price":"4.00","trade_state":"TRADE_SUCCESS","hk_orderid":"1576120657890"}}
12/12/2019 12:17:57 PM (node:21) UnhandledPromiseRejectionWarning: SyntaxError: Unexpected token in JSON at position 0
12/12/2019 12:17:57 PM at JSON.parse (<anonymous>)
12/12/2019 12:17:57 PM at /usr/src/app/routes/notify.js:39:26