any way to give `Pair` a different name for `first...
# announcements
s
any way to give
Pair
a different name for
first
and
second
when json serializing?
🚫 2
t
I think you have to use a data class
s
yeah that's what I thought.
a
are you using jackson?
s
@agomez yes
a
you can register a mixin to customize pair serialization
mixins are handy when you need to customize the serialization of classes from 3rd party libraries
s
Awesome. I have no clue how I've never heard of those before. Thank you very much
@agomez ah would this 'permanently' make Pair serialize into a different 'class'?
n
it will be much easier and concise just to create specialized data class then going with Mixins
s
@nerses well I would really like to retain the ability to use the
to
infix
a
it will apply to pair everywhere
s
@agomez yeah what I was really looking for was essentially a
typealias
but with named params, or a subclass where I could just override the properties, but it's final so I can't.
n
i haven’t tried but you can import your own
to
infix method
s
ah, didn't realize you could overload it.
n
it’s just a method in standard lib
so in theory you should be able to do that
a
or create another infix function similar to
to
but with another name
d
You can also write a custom serializer and annotate the
Pair
fields you want to be treated specially.
s
Yeah I had thought of those other solutions. Thanks for all the advice guys/girls!
👍 1