When receiving a websocket message, I often encounter a response in the form of a string like this:
odds.1:[{"id":1,"marketType":10,"name":"Double chance","status":"HandedOver","specifiers":"","Outcomes":[]},{"id":2,"marketType":11,"name":"Draw no bet","status":"HandedOver","specifiers":"","Outcomes":[]},{"id":3,"marketType":1,"name":"1x2","status":"HandedOver","specifiers":"","Outcomes":[]}]
I am looking to parse this as a JSON array, but I am uncertain about the correct method...
https://gist.github.com/fogofogo/4f984c3c5655b5ee0f1b01840fc01b81
(please note that I also need to remove 'odds.1' from the string)
Here are some methods I have attempted, but they did not yield the expected results:
- message.json()
- JSON.stringify(message)
- JSON.parse(message)