Untitled

 avatar
unknown
plain_text
5 months ago
801 B
6
Indexable
import json

# Dosya yolunu belirleyin
file_path = '1.txt'

# Dosyayı açıp içeriği okuyun
with open(file_path, 'r', encoding='utf-8') as file:
    raw_data = file.read()

# JSON stringi temizle
if raw_data.startswith('"') and raw_data.endswith('"'):
    # İlk ve son çift tırnağı kaldır
    raw_data = raw_data[1:-1]
    # Çift tırnakları düzelt
    raw_data = raw_data.replace('""', '"')

try:
    # JSON'u parse edin
    parsed_data = json.loads(raw_data)

    # Düzeltilmiş JSON'u dosyaya yaz
    with open(file_path, 'w', encoding='utf-8') as file:
        json.dump(parsed_data, file, indent=4, ensure_ascii=False)

    print(f"JSON başarıyla düzeltildi ve '{file_path}' dosyasına kaydedildi!")

except json.JSONDecodeError as e:
    print(f"JSON çözümleme hatası: {e}")
Editor is loading...
Leave a Comment