I'm new to the Spray-Json API and I'm trying to parse a Json response from the Docker REST API.
There is a clean example of the usage of Spray-Json to parse this Google Map Json response :
{
"results" : [
{
"elevation" :…
Not sure this is a bug, but the following demo fails on the final cases:
import spray.json._
import DefaultJsonProtocol._
object SprayTest {
1.toJson
"".toJson
(Left(1): Either[Int, String]).toJson
(Right(""): Either[Int, String]).toJson
…
I'm working with a legacy HTTP API (that I can't change) that responds with JSON in the body, but gives a Content-Type: text/plain; charset=utf-8 header.
I am attempting to unmarshall that HTTP body as JSON, but I get the following exception:…
I have a User model
case class User(name: String, email: String, password: Option[String] = None, key: Option[UUID] = None)
With a spray-json marshaller
object UserJsonSupport extends DefaultJsonProtocol with SprayJsonSupport {
implicit val…
I'm trying (and failing) to get my head around how spray-json converts json feeds into objects. If I have a simple key -> value json feed then it seems to work ok but the data I want to read comes in a list like this:
[{
"name": "John",
…
I have this route:
val routes =
pathPrefix("api") {
path("ElevationService" / DoubleNumber / DoubleNumber) { (long, lat) =>
post {
requestContext =>
println(long, lat)
}
}
}
This works…
I'm trying to reprocude this or this, but I keep getting an error I am not able to fix...
First of all, here are my dependencies:
compile 'io.spray:spray-can_2.11:1.3.1'
compile 'io.spray:spray-routing_2.11:1.3.1',
compile…
I'm creating custom json readers for case classes but it can't find implicit JsonReader type class for List[T] which is used in other case class.
When I checked DefaultJsonProtocol, it has implicit format for collections already;
implicit def…
I am trying to return a List from my complete directive in spray-routing.
complete {
List("hello")
}
However, I am getting an error -
Expression of type List[String] doesn't conform to expected type ToResponseMarshallable
I am getting the same…
I have a case class containing varargs, with an implicit jsonFormat as follows:
import spray.json._
case class Colors(name: String*)
object MyJsonProtocol extends DefaultJsonProtocol {
implicit val colorFormat = jsonFormat1(Colors)
}
import…
Following the tutorial from http://www.smartjava.org/content/first-steps-rest-spray-and-scala, there are some unexpected error messages. What is going on? Have I defined implicit JsonWriter by the implicit val personFormat = jsonFormat3(Person)…
Here is spray-json example. Here is NullOptions trait.
The problem is when I declare a case class say
object MyJsonProtocol extends DefaultJsonProtocol {
implicit val some: RootJsonFormat[Some] = jsonFormat2(Some)
}
case class Some (
…
I'm finding myself in a situation in which I need to serialize into JSON a non case class.
Having a class as:
class MyClass(val name: String) {
def SaySomething() : String = {
return "Saying something... "
}
}
I've created a JsonProtocol…
When spray (spray.io) produces a rejection, it responds with a string body. Since all my API clients will assume that my API only returns json, I'd like globally make every rejection a valid json object that conforms to our error object format. How…
In some cases default values make more sense than optionals in case classes:
case class Car(numberOfWheels:Int = 4, color:String)
case class Car(numbeOfWheels:Option[Int], color:String) //silly
In the first case I'd expect to be able to easily…