Thread
#jackson-kotlin
    s

    Slackbot

    1 year ago
    This message was deleted.
    Dan

    Dan

    1 year ago
    Trying this:
    data class TransferQuoteRequest(
        @JsonProperty("sendCcy")
        val sendCcy: Currency,
        val receiveCcy: Currency,
        val amount: BigDecimal,
    
        @JsonProperty("isSendCcy")
        val isSendCcy: Boolean
    )
    Gives:
    Conflicting/ambiguous property name definitions (implicit name 'isSendCcy'): found multiple explicit names: [sendCcy, isSendCcy], but also implicit accessor:re
    d

    dinomite

    1 year ago
    Terminology note: serialize an object into JSON, deserialize from JSON into an object
    This has to do with the unfortunateness of the Java Beans specification around boolean field naming
    Dan

    Dan

    1 year ago
    Interesting. Is it then best to stay away from fields beginning with
    is
    ?
    d

    dinomite

    1 year ago
    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
    Dan

    Dan

    1 year ago
    Well changing the field name to something else (
    amountInSendCcy
    ) worked fine
    d

    dinomite

    1 year ago
    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?
    Dan

    Dan

    1 year ago
    Great. Thanks Drew, that’s really helpful
    Nope, just abbreviating. Ccy is a common abbreviation for currency
    d

    dinomite

    1 year ago
    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
    Dan

    Dan

    1 year ago
    Ah I see-- Yeah, we’re not there yet 🙂