Skip to content

Commit

Permalink
Upgrade klaxon library
Browse files Browse the repository at this point in the history
  • Loading branch information
MMauro94 committed Oct 28, 2021
1 parent 501ac29 commit bfe60c8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ repositories {

dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.31"
implementation 'com.beust:klaxon:5.0.5'
implementation 'com.beust:klaxon:5.5'

testImplementation group: 'junit', name: 'junit', version: '4.12'
testImplementation "org.jetbrains.kotlin:kotlin-test:1.5.31"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,18 @@ internal object BigIntegerConverter : Converter {

override fun canConvert(cls: Class<*>) = cls == BigInteger::class.java

override fun fromJson(jv: JsonValue) = jv.long()?.toBigInteger() ?: jv.bigInteger
override fun fromJson(jv: JsonValue): BigInteger? {
return when (val long = jv.long()?.toBigInteger()) {
null -> {
when (val inside = jv.inside) {
is BigInteger -> inside
null -> null
else -> throw KlaxonException("Invalid type ${jv.type} for BigInteger")
}
}
else -> long
}
}

override fun toJson(value: Any): String {
return if (value is BigInteger) value.toString()
Expand Down

0 comments on commit bfe60c8

Please sign in to comment.