I have not used this library, so I'm not sure if this is the right approach: (I came up with this by spending a couple of minutes on the documents)
class IntervalSerializer extends CustomSerializer[Interval](format => ( { case x: JObject => x.obj.sortBy { case (k,_) => k } match { case JField("end", JInt(e)) :: JField("start", JInt(s)) :: Nil => new Interval(start = s.longValue(), end = e.longValue()) } }, { case x: Interval => JObject(JField("start", JInt(BigInt(x.startTime))) :: JField("end", JInt(BigInt(x.endTime))) :: Nil) } ))
The idea is to sort the fields alphabetically and then create an Interval class.
source share