fix: json pretty printing rules causing issues

This commit is contained in:
Linnea Gräf
2025-06-18 01:00:40 +02:00
parent b79d137a7d
commit 79939812a1

View File

@@ -66,6 +66,8 @@ object Firmament {
} }
val version: Version by lazy { metadata.version } val version: Version by lazy { metadata.version }
private val DEFAULT_JSON_INDENT = " "
@OptIn(ExperimentalSerializationApi::class) @OptIn(ExperimentalSerializationApi::class)
val json = Json { val json = Json {
prettyPrint = DEBUG prettyPrint = DEBUG
@@ -73,20 +75,21 @@ object Firmament {
allowTrailingComma = true allowTrailingComma = true
ignoreUnknownKeys = true ignoreUnknownKeys = true
encodeDefaults = true encodeDefaults = true
prettyPrintIndent = "\t" prettyPrintIndent = if (prettyPrint) "\t" else DEFAULT_JSON_INDENT
} }
/** /**
* FUCK two space indentation * FUCK two space indentation
*/ */
val twoSpaceJson = Json(from = json) { val twoSpaceJson = Json(from = json) {
prettyPrint = true
prettyPrintIndent = " " prettyPrintIndent = " "
} }
val gson = Gson() val gson = Gson()
val tightJson = Json(from = json) { val tightJson = Json(from = json) {
prettyPrint = false prettyPrint = false
// Reset pretty print indent back to default to prevent getting yelled at by json // Reset pretty print indent back to default to prevent getting yelled at by json
prettyPrintIndent = " " prettyPrintIndent = DEFAULT_JSON_INDENT
encodeDefaults = false encodeDefaults = false
explicitNulls = false explicitNulls = false
} }