'How is Firefox converting output of a websocket to JSON?
I've got the following output in my console on Firefox and I wonder how Firefox is converting the message from a socket to JSON.
The return message look like the following raw:
a["MESSAGE\ntype:READY\ndestination:/user/request-response\ncontent-type:text/plain;charset=UTF-8\nsubscription:/user/request-response\nmessage-id:hantadlb-275772248\ncontent-length:0\n\n\u0000"]
and
a["MESSAGE\nid:/api/items/list/soccer-classes-with-match-events\ndestination:/user/request-response\ntype:FULL\ncontent-type:application/json\nsubscription:/user/request-response\nmessage-id:hantadlb-275772259\ncontent-length:1727\n\n{\"id\":\"soccer-classes-with-match-events\",\"valid\":true,\"lastTouched\":\"2022-03-05T08:53:37.997+00:00\",\"versionTag\":12,\"lastModified\":\"2022-03-05T08:51:37.674+00:00\",\"itemIds\":[{\"id\":\"soccer-gr\"},{\"id\":\"soccer-uk\"},{\"id\":\"soccer-es\"},{\"id\":\"soccer-it\"},{\"id\":\"soccer-de\"},{\"id\":\"soccer-fr\"},{\"id\":\"soccer-pt\"},{\"id\":\"soccer-nl\"},{\"id\":\"soccer-int31\"},{\"id\":\"soccer-be\"},{\"id\":\"soccer-tr\"},{\"id\":\"soccer-br\"},{\"id\":\"soccer-int33\"},{\"id\":\"soccer-ar\"},{\"id\":\"soccer-mx\"},{\"id\":\"soccer-at\"},{\"id\":\"soccer-za\"},{\"id\":\"soccer-sco\"},{\"id\":\"soccer-ch\"},{\"id\":\"soccer-int40\"},{\"id\":\"soccer-se\"},{\"id\":\"soccer-ro\"},{\"id\":\"soccer-au\"},{\"id\":\"soccer-jp\"},{\"id\":\"soccer-lt\"},{\"id\":\"soccer-dz\"},{\"id\":\"soccer-ao\"},{\"id\":\"soccer-am\"},{\"id\":\"soccer-az\"},{\"id\":\"soccer-bh\"},{\"id\":\"soccer-bo\"},{\"id\":\"soccer-bg\"},{\"id\":\"soccer-cl\"},{\"id\":\"soccer-co\"},{\"id\":\"soccer-cr\"},{\"id\":\"soccer-hr\"},{\"id\":\"soccer-cy\"},{\"id\":\"soccer-cz\"},{\"id\":\"soccer-dk\"},{\"id\":\"soccer-ec\"},{\"id\":\"soccer-sv\"},{\"id\":\"soccer-ee\"},{\"id\":\"soccer-fo\"},{\"id\":\"soccer-fi\"},{\"id\":\"soccer-ge\"},{\"id\":\"soccer-gh\"},{\"id\":\"soccer-hn\"},{\"id\":\"soccer-hu\"},{\"id\":\"soccer-is\"},{\"id\":\"soccer-in\"},{\"id\":\"soccer-id\"},{\"id\":\"soccer-ir\"},{\"id\":\"soccer-ie\"},{\"id\":\"soccer-il\"},{\"id\":\"soccer-ivory-coast\"},{\"id\":\"soccer-kz\"},{\"id\":\"soccer-kw\"},{\"id\":\"soccer-my\"},{\"id\":\"soccer-ma\"},{\"id\":\"soccer-ni\"},{\"id\":\"soccer-pa\"},{\"id\":\"soccer-py\"},{\"id\":\"soccer-pe\"},{\"id\":\"soccer-pl\"},{\"id\":\"soccer-kr\"},{\"id\":\"soccer-sa\"},{\"id\":\"soccer-sn\"},{\"id\":\"soccer-simulated-reality-league-(virtual)\"},{\"id\":\"soccer-sg\"},{\"id\":\"soccer-sk\"},{\"id\":\"soccer-si\"},{\"id\":\"soccer-th\"},{\"id\":\"soccer-tn\"},{\"id\":\"soccer-us\"},{\"id\":\"soccer-ae\"},{\"id\":\"soccer-uy\"},{\"id\":\"soccer-ve\"},{\"id\":\"soccer-vn\"},{\"id\":\"soccer-wf\"}]}\u0000"]
Is there any easy way to convert this to JSON without cleaning and formatting the data with a custom function?
I know in general a code example of what I tried is needed but I'm simply asking if there's a built-in function or a library that can do this for me instead of writing the code myself.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

