『瀚思彼岸』» 智能家居技术论坛

 找回密码
 立即注册
查看: 8648|回复: 0

[流程系列] 如此返回结果如何转换成json?用于nodered流程操作【求教】

[复制链接]

65

主题

853

帖子

3044

积分

论坛元老

Rank: 8Rank: 8

积分
3044
金钱
2184
HASS币
40
发表于 2021-3-31 20:26:37 | 显示全部楼层 |阅读模式
最近打算把小爱拦截的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)
集合这部分该如何写?求教
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

Archiver|手机版|小黑屋|Hassbian

GMT+8, 2024-11-21 23:40 , Processed in 0.067948 second(s), 22 queries .

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表