spray-json icon indicating copy to clipboard operation
spray-json copied to clipboard

No implicit arguments of type: JsonReader[Double]

Open JesseStutler opened this issue 3 years ago • 1 comments

I want to convert a JsValue to Double. Code is here: action.annotations.get("average_cpu").getOrElse(JsNumber(0)).convertTo[Double], Don't care about the logic, I get a Option[JsValue] here and use getOrElse method to get JsValue type. Then I want to convert to Double, but the IDE kept telling me an error:No implicit arguments of type: JsonReader[Double] And when I built my project, there was an error: Cannot find JsonReader or JsonFormat type class for Double action.annotations.get("average_cpu").getOrElse(JsNumber(0)).convertTo[Double], How to solve it ?

JesseStutler avatar Mar 02 '22 07:03 JesseStutler

The format is here.

Let me tell you that this is absolutely not the way to open an issue. You are not showing any complete code snippet that may be reproducible by anybody else. You're saying "the IDE" without even saying which IDE is. You haven't built a minimal reproducible example of how this supposed bug may be reproducible.

That said, try import spray.json.DefaultJsonProtocol._

TonioGela avatar Apr 19 '22 09:04 TonioGela