My function receives a JSON string that may have syntax error, how can I fix the error in my function so that I can call JSON.parse()?
Question story: I want to parse the command output of sudo lshw -class network -json which is a linux command. For example, the PC has 2 NICs, so the command output has 2 JSON objects. An exmpale is as following:
{
"businfo" : "pci@0000:01:00.0",
some other keys
}
{
"businfo" : "usb@1:4",
some other keys
}
NOTE: the 2 objects has no "," seperator. So JSON.parse() will generate error.
ODD: another hyper-v vm's lshw has the same version as used above, but it can generate correct JSON with "," between 2 objects. Same command line.