I have a JSON file with comments shown below, I can't read the file in python as it is an invalid JSON file and I would like to have a pythonic way to remove all the lines in the file starting with /* as shown below:
/* 1 */
[{
"_id" : ObjectId("abe"),
"id" : "149",
"objectType" : "act"
}
/* 2 */
{
"_id" : ObjectId("abe415"),
"id" : "449899009",
"objectType" : "ity"
}]
I have tried the code below but getting the error in loads() of JSON: '''
import JSON
with open('data.json', 'r+',encoding='utf-8-sig') as handle:
fixed_json = ''.join(line for line in handle if not line.startswith('/*'))
final_data = json.loads(fixed_json)
print(final_data)
'JSONDecodeError: Expecting value: line 4 column 13 (char 16)'
Thanks in advance