-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
awolosz
committed
Sep 2, 2024
1 parent
e1fee02
commit 5d2061f
Showing
2 changed files
with
28 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import json | ||
|
||
def clean_values(data): | ||
if isinstance(data, dict): | ||
return {k: clean_values(v) for k, v in data.items()} | ||
elif isinstance(data, list): | ||
return [clean_values(item) for item in data] | ||
else: | ||
return None | ||
|
||
def modify_json_file(file_path): | ||
with open(file_path, 'r', encoding="utf-8") as file: | ||
data = json.load(file) | ||
|
||
modified_data = clean_values(data) | ||
|
||
with open("synopsis_empty", 'w') as file: | ||
json.dump(modified_data, file) | ||
return modified_data | ||
|
||
print(modified_data) | ||
|
||
# Replace 'your_file.json' with the path to your JSON file | ||
tmp1 = modify_json_file('../src/assets/synopsis_szit.json') | ||
print(tmp1) | ||
tmp2 = modify_json_file('../src/assets/synopsis_esv.json') | ||
print(tmp1 == tmp2) |