If I Convert my All objects in JSON form Then showing the array "Unexpected script " soo can u tell me if i have a Unwanted object in the given array then how can i filters this particular object not using key and value of the object its possible to filter the particular object here my code :-
var arr = [
'{"Topic":"TRACK","SID":"1","GPSlat":"634312740","GPSlong":"104014684","GPSat":"43788","GPSspd":"20","GPShead":"29499222","GPSepoch":"1638451303"}',
'{"Topic":"TRACK","SID":"1","GPSlat":"634312740","GPSlong":"104014684","GPSalt":"43788","GPSspd":"20","GPShead":"29499222","GPSepoch":"1638451303"}',
"{'143567890'}",
'{"Topic":"TRACK","SID":"1","GPSlat":"634312740","GPSlong":"104014684","GPSalt":"43788","GPSspd":"20","GPShead":"29499222","GPSepoch":"1638451303"}',
'{"Topic":"Impact","SID":"1","GPSlat":"634312740","GPSlong":"104014684","GPSalt":"43788","GPSspd":"20","GPShead":"29499222","GPSepoch":"1638451303"}'
];
my code:-
let output = [];
for (let i = 0; i < arr.length; i++)
{
var ReplaceData = arr[i].replace(/\\/g,'');
var Finaldata=JSON.parse(ReplaceData);
console.log
(Finaldata.GPSlat,Finaldata.GPSlong,Finaldata.SID,"11111111111",Finaldata);
}
my output:-
"634312740", "104014684", "1", "11111111111", {
GPSat: "43788",
GPSepoch: "1638451303",
GPShead: "29499222",
GPSlat: "634312740",
GPSlong: "104014684",
GPSspd: "20",
SID: "1",
Topic: "TRACK"
}
"634312740", "104014684", "1", "11111111111", {
GPSalt: "43788",
GPSepoch: "1638451303",
GPShead: "29499222",
GPSlat: "634312740",
GPSlong: "104014684",
GPSspd: "20",
SID: "1",
Topic: "TRACK"
}
"Script error."
showing the error and stop my loop soo how can i fixed this error ..