Commit 731a9fde authored by Him188's avatar Him188

Merge remote-tracking branch 'origin/master'

parents 227a22d3 17af6861
...@@ -214,9 +214,9 @@ open class ConfigSectionImpl() : ConcurrentHashMap<String, Any>(), ConfigSection ...@@ -214,9 +214,9 @@ open class ConfigSectionImpl() : ConcurrentHashMap<String, Any>(), ConfigSection
interface FileConfig : Config { interface FileConfig : Config {
fun deserialize(content: String): ConfigSectionImpl fun deserialize(content: String): ConfigSection
fun serialize(config: ConfigSectionImpl): String fun serialize(config: ConfigSection): String
} }
...@@ -244,31 +244,27 @@ abstract class FileConfigImpl internal constructor( ...@@ -244,31 +244,27 @@ abstract class FileConfigImpl internal constructor(
} }
override fun asMap(): Map<String, Any> { override fun asMap(): Map<String, Any> {
return content return content.asMap()
} }
} }
class JsonConfig internal constructor(file: File) : FileConfigImpl(file) { class JsonConfig internal constructor(file: File) : FileConfigImpl(file) {
@UnstableDefault @UnstableDefault
override fun deserialize(content: String): ConfigSectionImpl { override fun deserialize(content: String): ConfigSection {
if (content.isEmpty() || content.isBlank() || content == "{}") { if (content.isEmpty() || content.isBlank() || content == "{}") {
return ConfigSectionImpl() return ConfigSectionImpl()
} }
val section = ConfigSectionImpl() val section = JSON.parseObject(
val map: LinkedHashMap<String, Any> = JSON.parseObject(
content, content,
object : TypeReference<LinkedHashMap<String, Any>>() {}, object : TypeReference<ConfigSectionImpl>() {},
Feature.OrderedField Feature.OrderedField
) )
map.forEach { (t, u) ->
section[t] = u
}
return section return section
} }
@UnstableDefault @UnstableDefault
override fun serialize(config: ConfigSectionImpl): String { override fun serialize(config: ConfigSection): String {
return JSONObject.toJSONString(config) return JSONObject.toJSONString(config)
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment