I'm trying to convert a custom file to JSON for easy editing. Here is the custom code example:
{
"#letter_a" "A"
"#letter_b" "B"
"#letter_c" "C"
"#letter_d" "D"
"#letter_e" "E"
"#letter_f" "F"
"#letter_g" "G"
"#letter_h" "H"
"#letter_i" "I"
"#letter_j" "J"
"#letter_k" "K"
"#letter_l" "L"
"#letter_m" "M"
}
I need to add ':' at the end of keys then add ',' at the end of the line. Here is the code i tried:
import in_place
with in_place.InPlace('english_m.lang', encoding="utf-8", backup='.bak') as file:
for line in file:
cumle = line.join(line.split('"', 2)[:2])
print(line.replace(cumle, cumle+'":'), end='')
It didn't quite work, it always delete all the lines in the file.
How can i solve this problem or is there any way to just convert this file format to JSON?