I have a scala service that calls to TensorFlow service by HTTP. I'm trying to encode None value to NaN as JSON with circe (how TensorFlow expect it), but and I'm getting "null" after encoding the object
Suppose I have the following case class that need to be serialized as JSON objects using circe:
case class MyRequest(instance: Option[Double])
object MyRequest extends CirceDefaults {
implicit val autoEncoderRequestEncoder: Encoder[MyRequest] = { (myRequest: MyRequest) =>
myRequest.instance match {
case Some(value) => Json.fromDouble(value).asJson
case None => None.asJson
}
}
}
So None.asJson encoded to "null" and not NaN and im getting error from tensorflow service:
Error: Invalid argument: JSON Value: "null" Type: String is not of expected type: float"
Any help would be greatly appreciated.