If I have nested case classes, how can they be converted to JSON using spray-json?
For example my structure looks something like:
case class MyObj1(name: String, myObject2: MyObject2)
case class MyObj2(myObjec3s: Seq[MyObj3])
case class…
Using Spray with spray-json for a system, version:
"io.spray" %% "spray-json" % "1.2.6"
I cannot figure how to get custom JsonFormat definitions to work for serialization that is being handled by spray-routing.
I've had two separate circumstances…
When I try to GET amazon identity data like that
val pipeline: HttpRequest => Future[IdentityData] = sendReceive ~> unmarshal[IdentityData]
pipeline(Get("http://169.254.169.254/latest/dynamic/instance-identity/document"))
with appropriate case…
I am trying to use my domain objects as a request/response body parameters. I am using spray-routing and as[T] to unmarshall object. But constantly I'm getting could not find implicit value for parameter um:…
i`m trying here to find some help to apply an JsonFormat extended of the DefaultJsonProtocol
to an class containing a Sequence of Objects.
So for the classes:
class Person(val name: String, [......], val adresses: Seq[Adress])
class Adress(val…
I have the next code:
//models
case class Foo(name: String, age: Option[Int] = None)
//routing
trait FooRouting extends HttpService {
def index(foos: List[Foo]): twirl.api.Html = html.foo.render(foos)
val route =
path("") {
get…
I tried the tutorial of json spray but i have a different string where one value is a string and the other one is a list.
How do i convert the following string into a json object where each key is either a list or a string?
source = """{ "some":…
How can provide JsonFormats for case class that references itself ?
I'm following this guideline and wrote following code
case class Item(name: String, desc: Option[String], prices: Array[String], subitems: Option[List[Item]])
import…
I have a bunch of documents persisted in Apache Lucene with some names in russian, and when I'm trying to print them out it looks like this "\u0410\u0441\u043f\u0430\u0440", but not in cyrillic symbols. The project is in Scala. I've tried to fix…
I'm trying to write a generic extractor for parsing json POST body using spray and spray-json.
However I'm struggling to get it working with more than one model. Here's the case statement in the service object:
import MyJsonProtocol._
...
def…
I am trying to use Spray-JSON to marshall an incoming JSON with more than 22 fields. Since there is no JsonFormat23() method, I am having to nest my case classes to get around the limitation. However, the incoming JSON does not know of the nested…
So, I have this class:
case class Something[T](data: Option[T] = None)
And i register it like the instruction said in https://github.com/spray/spray-json and in https://doc.akka.io/docs/akka-http/current/common/json-support.html. Like this:
import…
I have a case class:
case class OpcTagPlaybook(name: String, tags: Seq[OpcTagAtTime], looped: Boolean, enabled: Option[String])
With an optional enabled field that will contain a date.
Spray Json describes encoding/decoding:
implicit val…
I am trying to simply create a json format for my case classes:
case class ImageRequest (inputs: Array[ImageObject])
case class ImageObject(data: Data)
case class Data(image: Image)
case class Image(url: String)
and here are the implicit…
I'm trying to write an actor that calls an HTTP REST API. The rest API needs a query parameter that will be passed from the invoking Actor. The official documentation has an example to achieve the above using a preStart method that pipes the message…