<@U5M5HU38C> Fixed in 2.1.10.
# klaxon
c
@nikbucher Fixed in 2.1.10.
🚀 1
n
I tried to add this by myself but I stuck at Klaxon line 215 🙂
c
You were in the right place, and that change allowed me to fix a potential bug in Klaxon, so thanks!
n
You're welcome
btw: I changed the first two tests to
Copy code
package com.beust.klaxon

import org.testng.Assert
import org.testng.annotations.Test

@Test
class JsonAnnotationTest {
    private val jsonString: String = json { obj(
            "name" to "John",
            "change" to 1
    ) }.toJsonString()

    fun ignoredWithAnnotation() {
        class IgnoredWithAnnotation(
                val name: String,
                @Json(ignored = true)
                val change: Int = 0)

        val result = Klaxon().parse<IgnoredWithAnnotation>(jsonString)
        Assert.assertEquals(result?.name, "John")
        Assert.assertEquals(result?.change, 0)
    }

    fun ignoredWithPrivate() {
        class IgnoredWithPrivate(
                val name: String,
                private val change: Int = 0){
            fun changed(): Boolean = change != 0
        }

        val result = Klaxon().parse<IgnoredWithPrivate>(jsonString)
        Assert.assertEquals(result?.name, "John")
        Assert.assertEquals(result?.changed(), false)
    }

    fun overrideIgnoredWithPrivateByAnnotation() {
        class OverrideIgnoredWithPrivate(
                val name: String,
                @Json(ignored = false)
                private val change: Int = 0){
            fun changed(): Boolean = change != 0
        }

        val result = Klaxon().parse<OverrideIgnoredWithPrivate>(jsonString)
        Assert.assertEquals(result?.name, "John")
        Assert.assertEquals(result?.changed(), true)
    }
}
because they don't fail, if you remove @Json(ignored = true) or private
c
Ah good catch, can you send a PR? (also, pull first, I just moved the new test to that file)
n
ok
should I add the overrideIgnoredWithPrivateByAnnotation method too?