0

I am having an issue with json4s where it is picking up the JDouble(NaN) and when I do a write to json,

 Serialization.write(json)

I am getting the output as a string in JSON "NaN" and it is causing conflicts when I am adding to records in my elastic search instance because its trying to figure out Double and String.

Is there a way to just replace it with a compatible type during the write?

I am not sure how to handle it in a custom serializer like so:

class NoneJNullSerializer extends CustomSerializer[Option[_]](format => ( {
  case JDouble(NaN) => JNull
}))

The NaN is not allowed in JDouble.

I've also tried in the JSON String to do something like

.replaceAll("NaN", null)

but than I get Exception in thread "main" java.lang.NullPointerException

theMadKing
  • 2,064
  • 7
  • 32
  • 59

0 Answers0