score:0

It seems that this will work:

implicit def emptyArrToEmptyDict[T: Reader]: Reader[Map[String, T]] = {
  reader[ujson.Value].map[Map[String, T]] {
    case ujson.Arr(array) if array.length == 0 => Map()
    case other => other.obj.map { case (k, v) => (k -> v.transform(implicitly[Reader[T]])) }.toMap
  }
}

uPickle should pick it up automatically if you put it in some object and you import the emptyArrToEmptyDict name to the global namespace.


Related Query

More Query from same tag