<?php
$jsonFile = 'c:\\xampp\\htdocs\\ecoms\\data\\products.json';
$data = json_decode(file_get_contents($jsonFile), true);
foreach($data as &$p) {
    if(empty($p['sr_no'])) $p['sr_no'] = $p['id'];
}
file_put_contents($jsonFile, json_encode($data, JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE));
echo "Complete";
?>
