A suite of scala libraries for building and consuming RESTful web services on top of Akka: lightweight, asynchronous, non-blocking, actor-based, testable
import com.konga.order.models.OrderJsonSupport._
import DefaultJsonProtocol._
RouteTest
in the testkit appears to eagerly create and start the actor system. While this normally wouldn't be an issue, we use ScalaTest's tagging to include/exclude tests. The eager loading slows things down considerably as the actor system will be initialized even though no tests are actually run.
@shankarshastri you can use spray-json.
import spray.json._
val jsonString: String = ???
val json: JsObject = jsonString.parseJson.asJsObject
or you can declare a class describing this json and declare format for it and then convert to it directly:
class JsonRepr(???)
implicit object ReprFormat extends RootJsonFormat[JsonRepr]{
???
}
import spray.json._
val jsonString: String = ???
jsonString.parseJson.convertTo[ReprFormat]
jsonString.parseJson.asJsObject.fields
will return Map[String, JsValue]
concat
instead of ~
which might be less prone to confusing IntelliJ - not sure if that was in Spray already though (https://doc.akka.io/docs/akka-http/current/routing-dsl/directives/index.html)
could not find implicit value for parameter m: akka.http.scaladsl.marshalling.Marshal
ler[eneovim.EnMessage,akka.http.scaladsl.model.ws.Message]
[error] val outgoing = Source.fromFuture(Marshal(myMsg).to[Message])
[error] ^
HttpEntity
? It works for those because of the implicit conversion at https://github.com/akka/akka-http/blob/master/akka-http-marshallers-scala/akka-http-spray-json/src/main/scala/akka/http/scaladsl/marshallers/sprayjson/SprayJsonSupport.scala#L65, you might want to introduce a similar one for Message
implicit def sprayJsonToWsMessageMarshaller[T](implicit writer: RootJsonWriter[T], printer: JsonPrinter = CompactPrinter): Marshaller[T, Message] =
Marshaller.strict(t => Marshalling.Opaque(() => TextMessage(writer.write(t))))
might work?