the json is prettier

main
ByrmGkcn 2023-12-07 14:06:15 +01:00
parent 45a9304c41
commit 1430821849
1 changed files with 3 additions and 2 deletions

View File

@ -663,13 +663,14 @@ fun chargerDonneesDepuisFichier(): List<Mot> {
} }
} }
private val json = Json { prettyPrint = true }
fun sauvegarderDonneesDansFichier(listeMots: List<Mot>) { fun sauvegarderDonneesDansFichier(listeMots: List<Mot>) {
try { try {
val content = Json.encodeToString(listeMots) val content = json.encodeToString(listeMots)
File("glossaire.json").writeText(content) File("glossaire.json").writeText(content)
} catch (e: IOException) { } catch (e: IOException) {
e.printStackTrace() e.printStackTrace()
// Handle the exception as needed
} }
} }