itnoles

    itnoles

    3 years ago
    @Derk-Jan Karrenbeld I am trying to run test on Fuel 3x on Forge, I get very weird errors from One of deserialize(ByteArray) or deserialize(InputStream) or deserialize(Reader) or deserialize(String) must be implemented
    d

    Derk-Jan Karrenbeld

    3 years ago
    Is one of those implemented?
    itnoles

    itnoles

    3 years ago
    Yes
    suspend inline fun <reified T : Any> Request.awaitResponseResultObject(noinline deserializer: JSON.() -> DeserializedResult<T>) = awaitResponseResult(forgeDeserializerOf(deserializer))
    d

    Derk-Jan Karrenbeld

    3 years ago
    That looks different
    itnoles

    itnoles

    3 years ago
    it supposed to be 🙂
    itnoles

    itnoles

    3 years ago
    it is very tough to see which one occurs 😞
    d

    Derk-Jan Karrenbeld

    3 years ago
    You need to either implement
    Deserializable
    and overwrite
    fun deserialize(response: Response): T
    , or implement
    ResponseDeserializable
    and override one of the methods
    suspend inline fun <reified T : Any> Request.awaitResponseResultObject(noinline deserializer: JSON.() -> DeserializedResult<T>) =
       awaitResponseResult(forgeDeserializerOf(deserializer))
    doesn't seem to do either of that?
    if I commit it with latest changes, would you figure out why?
    d

    Derk-Jan Karrenbeld

    3 years ago
    Yes, commit and I'll try to figure out what's wrong!
    itnoles

    itnoles

    3 years ago
    When I did println(String(response.data)), I see json. Odd. Something must be on deserialize
    d

    Derk-Jan Karrenbeld

    3 years ago
    Yeah, that is interesting!
    itnoles

    itnoles

    3 years ago
    Now I did override fun deserialize(content: String): T? { println(content) return Forge.modelFromJson(content, deserializer).component1() } I see another json lines.
    I think that compontent1() is null, so it throws
    d

    Derk-Jan Karrenbeld

    3 years ago
    yeah, null is not valid
    I think null = interpreted as no implementation
    itnoles

    itnoles

    3 years ago
    T? is Optional
    may be null 🙂
    d

    Derk-Jan Karrenbeld

    3 years ago
    can you make it return a "nothing empty object" thing 😛 ?
    see if that fixes it, for now?
    itnoles

    itnoles

    3 years ago
    i did val forge = Forge.modelFromJson(content, deserializer) println(forge.compontent2()), it comes up as com.github.kittinunf.forge.core.DeserializedResult$Failure@fe7548
    found it com.github.kittinunf.forge.core.PropertyNotFoundException: Property name status is not found
    d

    Derk-Jan Karrenbeld

    3 years ago
    so on error you get the INCORRECT error?
    on deserialization error you get a weird not implemente error
    that's a bug
    itnoles

    itnoles

    3 years ago
    since it is throwing exceptions, it is not catching it and return it as null.
    d

    Derk-Jan Karrenbeld

    3 years ago
    got it!
    sorry 😞
    probably my fault
    itnoles

    itnoles

    3 years ago
    private val httpBinUserDeserializer = { json: JSON -> ::HttpBinUserAgentModel.create .map(json at "userAgent") .apply(json at "status") } Hmm
    I think it is my fault because I switch Triple to Pair.
    {"method":"GET","path":"/user-agent","headers":{"TE":["gzip, deflate; q=0.5"],"content-length":["0"],"Accept":["text/html, image/gif, image/jpeg, *; q=.2, /; q=.2"],"User-Agent":["Java/1.8.0_181"],"Connection":["keep-alive"],"Host":["localhost:54045"]},"reflect":true,"userAgent":"Java/1.8.0_181"} no status