Simple-Notes
Simple-Notes copied to clipboard
backup file schema
The schema of the backup .json file has apparently changed at some point(?), and the old format is not compatible with the current version. Here is a Python script that can be used to convert the old backup file to the current format
import json
def transform_dict_list(dict_list):
transformed_list = []
for original_dict in dict_list:
new_dict = {
"path": "",
"protectionHash": "",
"protectionType": -1,
"title": original_dict.get("title", ""),
"type": 0,
"value": original_dict.get("value", "")
}
transformed_list.append(new_dict)
return transformed_list
def read_json_file(file_path):
with open(file_path, 'r', encoding='utf-8') as file:
data = json.load(file)
return data
def save_dict_list_to_json(dict_list, file_path):
with open(file_path, 'w', encoding='utf-8') as file:
json.dump(dict_list, file, ensure_ascii=False, indent=4)
if __name__ == "__main__":
file_path = 'old_backup.json' #old backup file path
data = read_json_file(file_path) #read file to dict
transformated_data = transform_dict_list(data) #transformate data to new json schema
save_dict_list_to_json(transformated_data,"backup.json") #save data to .json file