spray / spray-json

A lightweight, clean and simple JSON implementation in Scala
Apache License 2.0
969 stars 190 forks source link

No implicit arguments of type: JsonReader[Double] #347

Closed JesseStutler closed 1 year ago

JesseStutler commented 2 years ago

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 ?

TonioGela commented 2 years ago

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._