Created
March 25, 2026 02:33
-
-
Save lixingcong/abefa266ac1f8a651bd410873d8b2101 to your computer and use it in GitHub Desktop.
移除bitwarden导出json的无关键
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 用于bitwarden导出的明文json文件,删除对应的json键 | |
| # 目的是用于BeyondCompare或者meld手工对比两份密码库的差异 | |
| import json | |
| def remove_key(d: dict, k: str): | |
| if k in d: | |
| del d[k] | |
| def cleanup(filename:str): | |
| with open(filename, 'r', encoding='utf-8') as f: | |
| j = json.load(f) | |
| for i in j['folders']: | |
| remove_key(i, 'id') | |
| for i in j['items']: | |
| remove_key(i, 'revisionDate') | |
| remove_key(i, 'creationDate') | |
| remove_key(i, 'id') | |
| remove_key(i, 'folderId') | |
| remove_key(i, 'collectionIds') | |
| with open(f'0_{filename}', 'w', encoding='utf-8') as out_file: | |
| json.dump(j, out_file, indent=4, ensure_ascii=False) | |
| if __name__ == '__main__': | |
| cleanup('aaa.json') | |
| cleanup('bbb.json') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment