最近打算把小爱拦截的nodered搞一下,发现使用了新固件版本后,拦截词返回的信息如下:
asr="{"header":{"dialog_id":"aaac56151d5f587eff067970877d18f5","id":"be9a6833b5af4672b1a90bdf9819f9a2","name":"RecognizeResult","namespace":"SpeechRecognizer"},"payload":{"is_final":false,"results":[{"confidence":0.0,"text":""}]}}
{"header":{"dialog_id":"aaac56151d5f587eff067970877d18f5","id":"6dc0eeb20bf341dd94c80237b107abbc","name":"RecognizeResult","namespace":"SpeechRecognizer"},"payload":{"is_final":false,"results":[{"confidence":0.0,"text":"室内"}]}}
{"header":{"dialog_id":"aaac56151d5f587eff067970877d18f5","id":"f9134a82028d414a8263862117eed8ad","name":"RecognizeResult","namespace":"SpeechRecognizer"},"payload":{"is_final":false,"results":[{"confidence":0.0,"text":"室内空气"}]}}
{"header":{"dialog_id":"aaac56151d5f587eff067970877d18f5","id":"e59292cd51804d1b95a3ab05b9eceb75","name":"RecognizeResult","namespace":"SpeechRecognizer"},"payload":{"is_final":true,"results":[{"confidence":0.0,"text":"室内空气"}]}}"
如此整体并非标准的json格式,但是每个{"header":{},"payload":{}}单元却是一个完整的json结构,如此格式的返回信息如何整体转换成json给nodered处理?
queries = JSON.parse(msg.payload.asr)
集合这部分该如何写?求教
|