I have a socket connected to a third party and I receive data using websockets. At times data received through socket could have a string containing multiple sets of array.
How to handle this while parsing?
for ex, data I receive normally:
[{a:1}, {b:2}, {c:3}]
at times, I receive:
[{a:1}, {b:2}, {c:3}][{d:1}, {e:2}, {f:3}]
and I get below error, because i guess JSON.parse does not know what to do with it:
Uncaught SyntaxError: Unexpected token [ in JSON at position 267
at JSON.parse (<anonymous>)
I would want to split and parse both json array. so my new output would be:
[{a:1}, {b:2}, {c:3}] as arr[0] and [{d:1}, {e:2}, {f:3}] as arr[1]