Skip to content

Commit

Permalink
fixed an issue with getString
Browse files Browse the repository at this point in the history
  • Loading branch information
RealYusufIsmail committed Sep 11, 2022
1 parent 445fd24 commit 771dba6
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extra.apply {
}

group = "io.github.realyusufismail"
version = "1.0.1"
version = "1.0.2"

repositories {
mavenCentral()
Expand Down
12 changes: 10 additions & 2 deletions src/main/kotlin/io/github/realyusufismail/jconfig/JConfigUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
}
}

/**
Expand All @@ -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
}
}

/**
Expand Down

0 comments on commit 771dba6

Please sign in to comment.