I get this Json string from a web api:
{"results":{"Inne":"23.3","Ute":"5.8"}}
How do I construct a case class to match this output?
This is my attempt:
case class Results(Inne: String, Ute: String)
object MyJsonProtocol extends…
We are in the process of migrating an existing REST service from Spring/Java to Spray using ReactiveMongo. One of the requirements for the migration (the first phase of it anyway), is that all inputs and outputs must match the current system. The…
My requirement is creating a json like
"filters":{
"key1":"value1",
"key2":"Value2",
"key3":"Value3",
.........
},
Here the all the keys and values name are different. i.e.keys are not fixed type.Also the number…
I'm trying to get list of ints [1,2,3,...] from JSON api but I see conversion to generic type isn't working and Spray documentation is only showing unmarshalling to specific object. Any ideas how to make it work / what to google to get my…
I'm trying to merge a Github pull request using spray. Github's API will return different values depending on whether it succeeds or fails.
How do I parse that into an Either?
Using the following imports:
import akka.actor.ActorSystem
import…
I'm trying to marshal some custom objects to JSON in one of my responses and can't seem to get the logic right. I suspect this is a straight forward issue, but I just can't seem to find the solution anywhere.
I have the following which is…
I am creating a service that aggregates data and will need to be able to read any unknown JSON document. I have the pipeline defined as follows:
private def pipeline = (
addHeader("Accept", "application/json")
~> sendReceive
~>…
I have the following this matcher:
def haveBodyWith[T: TypeTag: Unmarshaller](content: T)(implicit await: Duration): Matcher[Future[HttpResponse]] = {
===(content) ^^ { (f: Future[HttpResponse]) => { Await.result(f, await).entity.as[T].right.get…
I am a Spray newby, somewhat proficient in Scala, and although the Spray documentation is overall very good, I can't find any relevant example for my problem. I am trying to do something very simple: serialize (or Marshall) a Scala Array of my…
I'm using spray-json 1.3.0. I have a simple piece of Json that I am asking spray to parse, here it is
import org.scalatest.{FlatSpec, MustMatchers}
import spray.json._
class BlockCypherOutputMarshallerTest extends FlatSpec with MustMatchers {
…
I have domain model like:
sealed trait MyTrait
case class MyObject(a: String) extends MyTrait
case class MyArray(a: Seq(MyObject)) extends MyTrait
Example usages would look like:
// array
[{"a": "foo"}, {"a": "bar"}]
//object
{"a": "foobar"}
I…
I have a custom class as follows
object SafeList {
def apply[A](x: List[A]): SafeList[A] = if (x == null) EmptyList else HasItems[A](x)
}
sealed abstract class SafeList[+A] extends Product with Serializable {
def get: List[A]
}
final case…
I'm using Scala / Slick 3.1 (This is all through the spray-slick-swagger typesafe activator) and have 4 different queries running that I want to return as one object. I'm trying to compose all the futures together into one future.
It works, but the…
There is an existing question that has much of what I'm after:
Extracting Raw JSON as String inside a Spray POST route
But it stops short without explaining how to get the actual Json string representation out of the Directive[String]. I'm trying to…
For some reason, my code wont resolve this symbol "respondWithMediaType" despite having all necessary imports. I'm fairly new to both spray and scala - so perhaps missing something obvious?
import spray.http.MediaTypes._
import spray.json._
…