JSON encode defaults

This commit is contained in:
Him188 2020-12-18 16:52:39 +08:00
parent 02345597ac
commit b3b34c19d1
4 changed files with 12 additions and 5 deletions

View File

@ -39,9 +39,12 @@ public open class AutoSavePluginData private constructor(
public final override val saveName: String
get() = _saveName
private var _saveName: String = saveName
@Suppress("JoinDeclarationAndAssignment") // bug
private lateinit var _saveName: String
public constructor(saveName: String) : this(null)
public constructor(saveName: String) : this(null) {
_saveName = saveName
}
@ConsoleExperimentalApi
override fun onInit(owner: PluginDataHolder, storage: PluginDataStorage) {

View File

@ -65,6 +65,7 @@ internal open class MultiFilePluginDataStorageImpl(
ignoreUnknownKeys = true
isLenient = true
allowStructuredMapKeys = true
encodeDefaults = true
}
private val yaml = Yaml.default

View File

@ -24,8 +24,11 @@ internal class PluginDataTest {
}
@Suppress("unused")
private val jsonPrettyPrint = Json { prettyPrint = true }
private val json = Json {}
private val jsonPrettyPrint = Json {
prettyPrint = true
encodeDefaults = true
}
private val json = Json { encodeDefaults = true }
@Test
fun testStringify() {

View File

@ -10,6 +10,6 @@
package net.mamoe.mirai.console.gradle
internal object VersionConstants {
const val CONSOLE_VERSION = "2.0-M1" // value is written here automatically during build
const val CONSOLE_VERSION = "2.0-M1-dev-1" // value is written here automatically during build
const val CORE_VERSION = "2.0-M1-dev-3" // value is written here automatically during build
}