diff --git a/build.gradle.kts b/build.gradle.kts index c0b0071..6130887 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -37,7 +37,7 @@ extra.apply { } group = "io.github.realyusufismail" -version = "1.0.1" +version = "1.0.2" repositories { mavenCentral() diff --git a/src/main/kotlin/io/github/realyusufismail/jconfig/JConfigUtils.kt b/src/main/kotlin/io/github/realyusufismail/jconfig/JConfigUtils.kt index fa4f4c7..9e4ceb2 100644 --- a/src/main/kotlin/io/github/realyusufismail/jconfig/JConfigUtils.kt +++ b/src/main/kotlin/io/github/realyusufismail/jconfig/JConfigUtils.kt @@ -33,7 +33,11 @@ class JConfigUtils { * @return The value of the specified key. */ fun getString(key: String): String { - return jConfig[key] as String + if (jConfig[key] is TextNode) { + return (jConfig[key] as TextNode).asText() + } else { + throw JConfigException("The value at the key $key is not a string.") + } } /** @@ -45,7 +49,11 @@ class JConfigUtils { * @return The value as a String. */ fun getString(key: String, defaultValue: String): String { - return jConfig[key, defaultValue] as String + return if (jConfig[key] is TextNode) { + (jConfig[key] as TextNode).asText() + } else { + defaultValue + } } /**