Last active
May 10, 2023 18:02
-
-
Save sonnguyen9800/bfd3d92b60cec566dd114f726cb1cfe0 to your computer and use it in GitHub Desktop.
Unstringlify Json file (Python)
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
import json | |
file_path = "file_path.txt" | |
file_path_output = "file_path_output.json" | |
f = open(file_path, "r", encoding='utf-16') | |
data_raw = f.read() | |
data_raw = data_raw.replace('\\', '') | |
data_raw = data_raw.replace('"{', '{') | |
data_raw = data_raw.replace('}"', '}') | |
# data = data.replace('"{', '{'); | |
data_json = json.loads(data_raw) | |
print(data_json) | |
with open(file_path_output, 'w') as f: | |
json.dump(data_json, f) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment