【发布时间】:2018-04-22 07:48:53
【问题描述】:
我收到一个 websocket 消息的消息响应,像这样的字符串
odds.1:[{"id":1,"marketType":10,"name":"Double chance","status":"HandedOver","specifiers":"","Outcomes":[ ]},{"id":2,"marketType":11,"name":"平局不下注","status":"HandedOver","specifiers":"","Outcomes":[]},{ "id":3,"marketType":1,"name":"1x2","status":"HandedOver","specifiers":"","Outcomes":[]}]
我想将它解析为这样的 json 数组,但不确定如何...
https://gist.github.com/fogofogo/4f984c3c5655b5ee0f1b01840fc01b81
(注意我也需要删除“odds.1”)
我尝试过但没有奏效的方法:
- message.json()
- JSON.stringify(消息)
- JSON.parse(消息)
【问题讨论】:
标签: javascript json websocket