I am facing an issue with Companion Objects picking up its type instead of the case class
I am using spray json serdes. They need an implicit JsonFormat. This format is obtained by calling a function that depends on the number of parameters of the…
spray-json relies on the presence of an in-scope, implicit JsonWriter[T] when calling toJson on an instance of T.
Say I have a trait with several concrete subtypes, each of which has a JsonWriter:
trait Base
case class Foo(a: Int) extends Base
case…
I have a case class called Recording that I can serialize correctly using spray-json, but I can't serialize a List[Recording].
The answers I've seen about List serialization involve missing imports of DefaultJsonProtocol._ but that hasn't helped me…
I've a problem about unmarshalling objects to Json via using spray - akka.
When i'd like to use actors that returns Future[List[Person]] , it doesn't work.
If i use dao object directly, it works.
Here are my codes:
PersonDao.scala
import…
My spray json support looks like this
object MarshallingSupport extends SprayJsonSupport {
implicit def json4sFormats: Formats = DefaultFormats
}
And in my route I want to map the request to a dto
object Main extends App with AppConfig with…
I'm using Spray to build a REST API.
One of my JSON datatypes are recursive:
case class Container(id: String,
name: String,
read_only: Boolean,
containers: List[Container],
…
I can process this json when all the inputs are valid, i.e with valid keys (including case) and values. The next step is to validate keys and return 400 (Bad Request) if the keys or values are invalid. What is a good way to add this validation?
The…
i'm got an error:
spray.json.ProductFormats$class.productElement2Field NullPointerException
Here is my code for json deserialisation:
object DomainJsonProtocol extends DefaultJsonProtocol {
implicit val loginInfoFormat = jsonFormat(LoginInfo,…
I am trying to write a test for a Post request
here is my code :
val request = CreateLinkRequest(token = Some(validToken),billing_ref_id = Some("123"), store_id = Some("123"), agent_id = Some("123"))
val endPoint = Uri(this.serverRootUrl +…
Given I have the following declaration:
sealed trait Color
case object DColor extends Color
case object CColor extends Color
case object VColor extends Color
And then I use them In a case class like so:
case class CustomColor(c:…
I am trying to parse a JSON string to a case class in Scala (So I can do the filtering data processing etc).
After some research I am going with spray-json as there are several examples on the link. Unfortunately the link does not show how to parse…
I'm trying to do some Scala JSON parsing in Spark. It work locally with my tests, but fails on a remote cluster.
Relevant Imports:
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.module.scala.DefaultScalaModule
import…
I know that has been asked already, but I can't seem to find an answer.
Here is my code :
import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport
import spray.json.DefaultJsonProtocol
final case class Client(clientId:Int,…
I am trying to run just the simple example from the documentation without any changes:
import spray.json.DefaultJsonProtocol
import spray.httpx.unmarshalling._
import spray.httpx.marshalling._
import spray.http._
import HttpCharsets._
import…
I try write test for spray
class FullTestKitExampleSpec extends Specification with Specs2RouteTest with UserController with HttpService {
def actorRefFactory = system
"The service" should {
"return a greeting for GET requests to the root…