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
0 answers

Akka Http JSON serialization is very slow

I'm measuring 3-4 ms serialization time of simple JSON. Is this the performance to expect from AKKA or is there something that can be done to rectify it? case class Response(msg: String) implicit val format = jsonFormat(Response) def…
Avba
  • 14,822
  • 20
  • 92
  • 192
0
votes
1 answer

Generic function to Spary JSON data types, throws type mismatch error

I'm using spray-json and I need to parse the given request body (PATCH, POST), request body attributes can have following possibilities represented by Either[Unit.type, Option[A]] value Not given Left[Unit.type] value=null Null …
Puneeth Reddy V
  • 1,538
  • 13
  • 28
0
votes
2 answers

Scala: Json sorting operations on a json file which has different datatypes but same schema

I have a json file which has two types of data for store and online.But datatypes of few columns are different ,but column names and schema are same. I would like to do some operations on json like sorting,re-arranging using spray joson library in…
Rohan Nayak
  • 233
  • 4
  • 14
0
votes
1 answer

How to read path value from JsonPatch?

Example: I have the below sample code: import spray.json._ import gnieh.diffson.sprayJson._ val patchString1 = """[{"op": "replace", "path": "/emails","value":["xxx@yyy.com"] }]""" val patchString2 = """[{"op": "replace", "path":…
Pratap D
  • 311
  • 3
  • 7
  • 14
0
votes
1 answer

Marshall Javascript Array to Seq[Any] with Spray JSON

I have a key-value pair where the value is an untyped Javascript array: {"data": [1, "abc", 54.0, "cdf"]} I want to convert the value to a Seq[Any] in Scala. Seq(1, "abc", 54.0, "cdf") So far I've tried: val jsonString =…
jstuartmill
  • 288
  • 5
  • 11
0
votes
0 answers

which is better multiple case class to map multi level json or reading it manually in read method

I have a json { "last_updated": "2018-06-04T02:44:54Z", "result": { "marks": { "math": 45.4, "physics": 13.5, "bio": 6.3 } } } Now to map above json shall I create multiple case classes or we should read it manually in spray…
Amit Prasad
  • 725
  • 4
  • 17
0
votes
1 answer

GeoTrellis/Scala: Locate missing implicit evidence for Json Parsing

What imports are needed to locate the implicit evidence to compile a call to GeoJson.parse from GeoTrellis? geotrellis.vector.io.json.Geometry uses spray.json to parse, and must be able to locate a JsonReader or JsonFormats instance, templated to…
Val H
  • 507
  • 4
  • 13
0
votes
2 answers

Spray Json: Get Json String from Generic objects

I have following classes import spray.json._ sealed trait Base case class Foo[K, V](key : K, value : V) extends Base case class Bar[K, V](key : V, value : K) extends Base their corresponding json convertors implicit def baseJsonConvertor[K:…
Puneeth Reddy V
  • 1,538
  • 13
  • 28
0
votes
1 answer

Same case class different validation

What I'm trying to do in Scala 2.11 and akka is have one case class but two different validations based on which route is being hit. For example, let's consider the case class below case class User(_id: String, name: String, age: Int, address:…
debduttoc
  • 304
  • 2
  • 9
0
votes
1 answer

Double quotes issue in retrieving value from json object

I am using Spray json and converting http response to json object in following way and fetching value of WebId key from it: val json = http_response.body.parseJson val web_id = json.asJsObject().getFields("WebId") println(web_id(0)) The output of…
Arshanvit
  • 417
  • 1
  • 7
  • 28
0
votes
1 answer

Marshaling akka-http

class Converter extends RootJsonFormat[TypeToConvert] { def write(obj : TypeToConvert) : JsValue = { obj match { case Https => JsString(Https.name) case Sms => JsString(Sms.name) } } def read(jsValue : JsValue) :…
0
votes
1 answer

Spray JSON: Flexibility Array/Object

Using Spray JSON, I would like to be able to parse an array of String, but still be able to deserialize correctly if a single String comes. That is, with this field: arrayval: List[String] and this JSON: arrayval: ["a", "b"] it would create a…
xmar
  • 1,729
  • 20
  • 48
0
votes
1 answer

Cannot find JsonWriter or JsonFormat type class

The below code is unable to find JsonWriter or JsonFormat type class: import com.typesafe.scalalogging.LazyLogging import spray.json._ case class MatcherRequest2(dataType:String, testType:String) object MatcherWriterJsonSupport2 extends…
binshi
  • 1,248
  • 2
  • 17
  • 33
0
votes
1 answer

properly unmarshalling trait in akka http

I've been through the docs and many questions on SO, still can't figure out what I'm doing wrong. I'm starting with a vanilla akka http g8 template, but I want to use a trait rather than a case class to represent the objects which are coming in POST…
jb44
  • 393
  • 1
  • 6
  • 23
0
votes
1 answer

Single List or list of lists json parsing failing

I have a json that sometimes returns List[List[x, y], List[a, b]] or if there is only one then List[x, y] ? My case class defines case class Geometry(dataType: String, coordinates: List[List[BigDecimal]]) Exception in thread…
binshi
  • 1,248
  • 2
  • 17
  • 33