import json
import os
import shutil
import time
# import objectpath
import sys
import datetime
true = "true"
false = "false"
null = "null"
from datetime import datetime, timedelta
with open('./notificationsManagement/notifications.json') as json_file:
data = json.load(json_file)
day_start = 30
for tuple in data:
tuple['creationTime'] -= int(timedelta(days = day_start).total_seconds())
day_start -= 2
print(data)
text_file = open("output.json", "w")
text_file.write(str(data))
text_file.close()
I wrote a script in order to:
- Read a Json File
- Execute a modification
- print the data
- Output a new valid Json file as "output.json"
A few problem I encourted:
- The Json's tuples are out of order
- The data is printed with an 'u' before each header
- The new file contains the same 'u' (Main problem)
Any suggestions?