How do I serialize Map[String, Any] with spray-json? I try
val data = Map("name" -> "John", "age" -> 42)
import spray.json._
import DefaultJsonProtocol._
data.toJson
It says Cannot find JsonWriter or JsonFormat type class for…
I understand that if I have:
case class Person(name: String)
I can use
object PersonJsonImplicits extends DefaultJsonProtocol {
implicit val impPerson = jsonFormat1(Person)
}
and thus serialize it with:
import…
I have an optional field on my requests:
case class SearchRequest(url: String, nextAt: Option[Date])
My protocol is:
object SearchRequestJsonProtocol extends DefaultJsonProtocol {
implicit val searchRequestFormat = jsonFormat(SearchRequest,…
I have this two erros:
Error:(39, 20) Cannot find an implicit ExecutionContext. You might pass
an (implicit ec: ExecutionContext) parameter to your method
or import scala.concurrent.ExecutionContext.Implicits.global.
val pipeline = sendReceive
…
I'm new to AJAX and javascript. In my project, I have to get a json object in my javascript file. I've used spray-json and it shows me the json object in the url. http://localhost:8081/all-modules
{
"status": "S1000",
"description": "Success",
…
I have a very simple question. This is not only true with spray-json but I have read similar claims with argonaut and circe. So please enlighten me.
In spray-json, I have come across the statement saying There is no reflection involved. I understand…
How to deserialize nested objects correctly in spray-json?
import spray.json._
case class Person(name: String)
case class Color(n: String, r: Int, g: Int, b: Int, p: Person)
object MyJsonProtocol extends DefaultJsonProtocol {
…
I have the following route setup, but when my map is returned in the first complete block I get an error:
could not find implicit value for evidence parameter of type…
I'm using spray-json to marshal lists of custom objects into JSON. I have the following case class and its JsonProtocol.
case class ElementResponse(name: String, symbol: String, code: String, pkwiu: String, remarks: String, priceNetto: BigDecimal,…
I'm using spray-json to serialize an object tree, which is based on a class hierarchy such as this:
trait Base {
val _id: Long
}
case class Person(_id: Long, firstName: String, lastName: String) extends Base
case class Company(_id: Long, name:…
I am using json-spray. It seems that when I attempt to print a parsed JsString value, it includes book-ended quotes on the string.
val x1 = """ {"key1": "value1", "key2": 4} """
println(x1.asJson)
println(x1.asJson.convertTo[Map[String,…
I am trying to use spray-json in scala to recognize the choice between Ec2Provider and OpenstackProvider when converting to Json and back.
I would like to be able to give choices in "Provider", and if those choices don't fit the ones available then…
I have such model: two enumerations and one case class with two fields of these enums types:
// see later, why objects are implicit
implicit object Fruits extends Enumeration {
val Apple = Value("apple")
val Orange = Value("orange")
}
implicit…
I have the following code which uses spray-json to deserialise some JSON into a case class, via the parseJson method.
Depending on where the implicit JsonFormat[MyCaseClass] is defined (in-line or imported from companion object), and whether there…