Skip to content

Instantly share code, notes, and snippets.

@sonnguyen9800
Last active May 10, 2023 18:02
Show Gist options
  • Save sonnguyen9800/bfd3d92b60cec566dd114f726cb1cfe0 to your computer and use it in GitHub Desktop.
Save sonnguyen9800/bfd3d92b60cec566dd114f726cb1cfe0 to your computer and use it in GitHub Desktop.
Unstringlify Json file (Python)
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