Skip to content

Commit a5e5516

Browse files
committed
chore(readme): update usage
1 parent 8afce54 commit a5e5516

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,15 @@ data class MyConfig(
3333

3434
class MyPlugin : JavaPlugin() {
3535
var myConfig: MyConfig = MyConfig("", null)
36+
val configJson: Json = Json { prettyPrint = true; encodeDefaults = true }
3637

3738
override fun onEnable(): Unit {
38-
this.myConfig = Json.Default.decodeFromString(File(dataFolder, "config.json").readText())
39+
this.myConfig = configJson.decodeFromString(File(dataFolder, "config.json").readText())
3940
// or Json.decodeFromString
4041
}
4142

4243
override fun onDisable(): Unit {
43-
File(dataFolder, "config.json").writeText(Json.Default.encodeToString(this.myConfig))
44+
File(dataFolder, "config.json").writeText(configJson.encodeToString(this.myConfig))
4445
// or Json.encodeToString
4546
}
4647
}

0 commit comments

Comments
 (0)