Questions tagged [spray-json]

Relates to the spray-json Scala library.

spray-json is a lightweight, clean and simple implementation in .

339 questions
5
votes
2 answers

Scala Case Class Companion Objects - Conflict on the type name

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…
xmar
  • 1,729
  • 20
  • 48
5
votes
3 answers

spray-json: Serialize a generic trait

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…
ChrisB
  • 4,628
  • 7
  • 29
  • 41
5
votes
0 answers

Serializing a List[case class] in spray-json

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…
jaegard
  • 171
  • 1
  • 7
5
votes
2 answers

Spray Akka Json Unmarshalling

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…
Bilal ALP
  • 111
  • 8
5
votes
1 answer

akka-http : could not find implicit value for parameter unmarshalling

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…
Reeebuuk
  • 1,363
  • 2
  • 21
  • 42
5
votes
1 answer

Lazy formatted recursive JSON type can't be found as implicit value

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], …
spydon
  • 9,372
  • 6
  • 33
  • 63
5
votes
2 answers

Scala, Akka, Spray: How to validate json data before processing?

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…
Srini K
  • 3,315
  • 10
  • 37
  • 47
5
votes
4 answers

Spray json parsing and NullPointerException

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,…
user443426
4
votes
1 answer

could not find implicit value for evidence parameter of type ^

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 +…
Lena Bru
  • 13,521
  • 11
  • 61
  • 126
4
votes
1 answer

trait with only case objects custom implementation in spray json

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:…
user3139545
  • 6,882
  • 13
  • 44
  • 87
4
votes
2 answers

Parse Complex JSON in SCALA using spray-json

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…
4
votes
0 answers

Deserialize/Parse JSON to Objects AbstractMethodError in Scala with Spray in Spark Cluster

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…
Chet
  • 21,375
  • 10
  • 40
  • 58
4
votes
3 answers

akka-http error: could not find implicit value for parameter um: akka.http.scaladsl.unmarshalling.FromRequestUnmarshaller

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,…
Sergey Malov
  • 71
  • 1
  • 1
  • 6
4
votes
1 answer

Can't unmarshall json HttpEntity with spray-json

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…
pkozlov
  • 746
  • 5
  • 17
4
votes
1 answer

Spray-Test gzip decode

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…
Rinat Mukhamedgaliev
  • 5,401
  • 8
  • 41
  • 59
1 2
3
22 23