I'm having trouble converting string {data}
to Json
, I get it separated by commas several times, I would like to convert it to Json
to collect the first key
var data = [ "$SP", "92", "00:01:36.340", "00:05:48.929\n" ];
var data = [ "$MT", "91", "00:00:34.187", "00:18:44.001\n" ];
the desired one would be:
{
"$SP":{
"0":92,
"1":"00:01:36.340",
"2":"00:05:48.929",
}
},
{
"$MT":{
"0":91,
"1":"00:00:34.187",
"2":00:18:44.001,
}
}