Questions tagged [spray-json]

Relates to the spray-json Scala library.

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

339 questions
0
votes
1 answer

Why does spray-json apply this hierarchy way in RootJsonFormat?

Recently, I am reading the source code of Spray-json. I noted that the following hierarchy relation in JsonFormat.scala, please see below code snippet /** * A special JsonFormat signaling that the format produces a legal JSON root * object, i.e.…
xyz
  • 413
  • 2
  • 19
0
votes
1 answer

Implicit JsonWriter for trait not working

I have class as below trait RiskCheckStatusCode { def code: String def isSuccess: Boolean } object RiskCheckStatusCode { val SUCCESS = SuccessRiskCheckStatusCode("1.1.1") val FAIL = FailRiskCheckStatusCode("2.2.2") case class…
mForest
  • 88
  • 11
0
votes
1 answer

Spray-Json serialize interface type

using spray-json how can I serialize following class case class Vegetable(name: String, color: String, seller:ISeller) here ISeller is a Java Interface. I am new to spray-json an not sure how this can be serialized and deserialized. I tried this…
Sandy
  • 2,253
  • 6
  • 24
  • 33
0
votes
1 answer

spray json: cannot convert to Array[myClass]

I am learning scala/spray json in my project and trying to convert an input json to an array of scala objects , but thats throwing the below error: Error:(52, 43) not enough arguments for method convertTo: (implicit evidence$1:…
Gary
  • 31
  • 4
0
votes
1 answer

Spray-JSON in an Apache Zeppelin Notebook

I am using Zeppelin notebooks to write a prototype for a Spark Streaming application. It receives small JSON messages via an event bus and I need to parse these in a (preferably) distributed manner. I chose spray-json to deserialize the individual…
Vinno97
  • 516
  • 3
  • 11
0
votes
1 answer

spray json nested class unable to deserialize

Unable to deserialize this using spray . I am unable to understand why the defaultJson protocol does not work. Please note I am new to scala and spray. case class Job(param1:Boolean,param2:String,joblist:List[JobList]) case class…
Siva
  • 21
  • 6
0
votes
0 answers

How to iterate and extract values from a list of objects

I am new to Scala and Spray. I have an input JSON that basically maps to these case classes. I have managed to get the json parsed and this the output I am seeing: case class First(param1:Boolean,param2:List[Parameter]) case class…
Siva
  • 21
  • 6
0
votes
0 answers

Dynamic Json Keys in Scala

I'm new to scala (from python) and I'm trying to create a Json object that has dynamic keys. I would like to use some starting number as the top-level key and then combinations involving that number as second-level keys. From reading the play-json…
0
votes
1 answer

spray-json deserialization issue

case class Box(id: String, container: Container) case class Container(id: String, boxes: List[Box]) object CustomProtocol extends DefaultJsonProtocol { implicit object BoxFormat extends RootJsonFormat[Box] { override def read(json:…
0
votes
1 answer

Spray Http Post request

Here is the code which I am trying to create a Post request through the spray http package org.exadatum.xstream.service.http import akka.actor.ActorSystem import akka.util.Timeout import spray.http._ import spray.httpx.SprayJsonSupport import…
Vishal
  • 1,442
  • 3
  • 29
  • 48
0
votes
1 answer

How to edit existing JSON object with sprayJSON

I am using akka with spray json support for which I need to edit value in the recieved json. import akka.http.scaladsl.server.Directives import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport import spray.json._ final case class…
Vishal
  • 1,442
  • 3
  • 29
  • 48
0
votes
1 answer

error - Spray-http: not found: type HttpBody

I am using till now spray - 1.1-M7 but now I changed to 1.3.3. There is HttpBody in 1.1-M7 but that was not exist in 1.3.3 version. So what is the alternative I have to do in my code. My code looks like this: What do I have to do to get: implicit…
Sun
  • 3,444
  • 7
  • 53
  • 83
0
votes
1 answer

How do I tell spray-json on Akka HTTP to "assume application/json"?

Using spray-json on an Akka HTTP server; how can I "assume Content-type: application/json" for requests when not supplied? Issue curl localhost:12345/request -d'{"sample":"json"}' doesn't work unless I add -H "Content-type:…
mlg
  • 1,447
  • 15
  • 19
0
votes
1 answer

"Expected List as JsArray" when posting to an akka-http server

I'm attempting to create a slight variation of the Orders/Items application here: https://github.com/akka/akka-http/blob/master/docs/src/test/scala/docs/http/scaladsl/SprayJsonExampleSpec.scala#L51 I'm connecting to the server using httpie, the…
FallingSkies
  • 121
  • 1
  • 10
0
votes
1 answer

Json deserialization of Scala case objects with spray-json

I am trying to write a custom JsonReader using spray-json for the following domain model: sealed trait OrderType object OrderType { case object MARKET extends OrderType case object LIMIT extends OrderType case object STOP extends OrderType …
msilb
  • 505
  • 6
  • 18