https://kotlinlang.org logo
#jackson-kotlin
Title
# jackson-kotlin
s

Slackbot

03/31/2021, 3:06 PM
This message was deleted.
d

Dan

03/31/2021, 3:11 PM
Trying this:
Copy code
data class TransferQuoteRequest(
    @JsonProperty("sendCcy")
    val sendCcy: Currency,
    val receiveCcy: Currency,
    val amount: BigDecimal,

    @JsonProperty("isSendCcy")
    val isSendCcy: Boolean
)
Gives:
Copy code
Conflicting/ambiguous property name definitions (implicit name 'isSendCcy'): found multiple explicit names: [sendCcy, isSendCcy], but also implicit accessor:re
d

dinomite

03/31/2021, 3:18 PM
Terminology note: serialize an object into JSON, deserialize from JSON into an object
👍 1
This has to do with the unfortunateness of the Java Beans specification around boolean field naming
d

Dan

03/31/2021, 3:19 PM
Interesting. Is it then best to stay away from fields beginning with
is
?
d

dinomite

03/31/2021, 3:20 PM
That, combined with the fact that
val
constructor parameters in Kotlin are really expanded to multiple things (a getter, setter, constuctor param, and field) makes for a very confusing situation
Yes, avoiding
is
is preferable, but in your case I don’t think that would help
You could make
isSendCcy
be
isSendCcyPresent
d

Dan

03/31/2021, 3:21 PM
Well changing the field name to something else (
amountInSendCcy
) worked fine
d

dinomite

03/31/2021, 3:21 PM
Or applying use site targets might help, too (e.g.
@get:JsonProperty("…")
) https://kotlinlang.org/docs/annotations.html#annotation-use-site-targets
Any reason for abbreviating currency?
d

Dan

03/31/2021, 3:23 PM
Great. Thanks Drew, that’s really helpful
Nope, just abbreviating. Ccy is a common abbreviation for currency
d

dinomite

03/31/2021, 3:26 PM
Fair enough; I often see abbreviations overused in an attempt to save bits on the wire when relying on compression (which is almost certainly already, transparently in place0 is a far better solution
Not to mention the fact that if bits matter then protobuf is the real answer
d

Dan

03/31/2021, 4:00 PM
Ah I see-- Yeah, we’re not there yet 🙂
10 Views