Questions tagged [play-json]

The play.api.libs.json package contains data structures for representing JSON data and utilities for converting between these data structures and other data representations.

The play.api.libs.json package contains data structures for representing JSON data and utilities for converting between these data structures and other data representations. It includes the following types:

  • JsString
  • JsNumber
  • JsBoolean
  • JsObject
  • JsArray
  • JsNull
313 questions
0
votes
1 answer

Scala case has 22 fields but having issue with play-json in scala 2.11.5

We are currently using scala 2.11.5 and 1 of my class has 22 fields. case class CreateTransactionRequest(name: Option[String], balance: Option[BigDecimal], amount: BigDecimal, …
dczii
  • 539
  • 5
  • 10
  • 20
0
votes
0 answers

scala error: bad symbolic reference

I was using sbt to compile a scala code, and got the following error message [error] /user/xyin/Projects/measurement_wspark/src/main/scala/json2csv.scala:41: bad symbolic reference. A signature in DefaultReads.class refers to term time [error] in…
xyin
  • 417
  • 2
  • 7
  • 19
0
votes
1 answer

extract case classes from json file scala play

im trying to extract my data from json into a case class without success. the Json file: [ { "name": "bb", "loc": "sss", "elements": [ { "name": "name1", "loc": "firstHere", "elements": [] } ] …
0
votes
1 answer

How can I iterate on a JsArray using Play JSON avoiding case classes?

Here's my use case: I need to access to an Array in a JSON document and then iterate on it in order to apply JSON coast-to-coast transformation to each object and get a collection of the transformed object. I was thinking about an approach like…
Max
  • 2,508
  • 3
  • 26
  • 44
0
votes
2 answers

Play Action Composition - hardcoding parameterized parser

I would like to create a custom action which takes away the boilerplate of writing actions like this: Action[MyClass](BodyParsers.parse.json[MyClass]) { req => ... However, I keep running into class definition errors. Here has been my most…
TheDarkSaint
  • 457
  • 3
  • 13
0
votes
1 answer

Scala play-json - doesn't parse/deserialize to single argument case class

In Scala, I want to parse JSON responses retrieved using the Travis CI REST API. For that, I've decided to use the play-json library. Along with this, and in accordance to the REST API 'schema', I've defined the following case classes: case class…
dsafa
  • 783
  • 2
  • 8
  • 29
0
votes
1 answer

Generic REST client in Scala

I'm a bit new to Scala and I'm trying to write a generic client for a RESTful api I would like to use. I'm able to provide concrete Reads[T] and Writes[T] for the specific case classes I would like to instantiate my client for, however the compiler…
Rag
  • 195
  • 1
  • 13
0
votes
1 answer

Play Framework JSON Conversion

I'm planning to use the Play JSON library to Serialize and De-Serialize objects to and from Json. I have a case class like this: case class MyCaseClass(string: String, intVal: Int) I have a service that returns me a JSON String which effectively is…
joesan
  • 13,963
  • 27
  • 95
  • 232
0
votes
1 answer

Play-Json parsing date time string to Reads[Instant]

I'm trying to enforce a validation rule that timestamps in input Json must have a timezone specified, using format DateTimeFormatter.ISO_OFFSET_DATE_TIME. When the input is incorrect, I want to return a message indicating bad format. This snippet…
Lost In Code
  • 494
  • 1
  • 5
  • 18
0
votes
2 answers

Play Json - Compare nested Json-Array with Specs2

With Play-Json and Specs2 I can match json-bodies like this: contentAsJson(res) must equalTo(responseBody) Is there a possiblity to ignore order (recursively) for json-arrays and instead treat equality for json-arrays like they were sets?
Tim Joseph
  • 847
  • 2
  • 14
  • 28
0
votes
1 answer

Extract Json attribute value from JsArray ( play )

Following is snippet from my scala code. I am using play 2.4. Below is the ouput of my "message" val. import play.api.libs.json._ .map{ _ match { case (Some( message :JsArray ), x) => { …
BalaB
  • 3,687
  • 9
  • 36
  • 58
0
votes
1 answer

Play Json case class mapper with custom converter function

I have a json which looks like this. { "key1": "val1", "key2": "val2", //other stuff "key5": { "nkey1": [ "nval1", "nval2" ], "nkey2": 90, "nkey3": 100 }, "page": 1, "rows": 30, "result_count": 3, "parser_result": null, "ip_address":…
Sohaib
  • 4,556
  • 8
  • 40
  • 68
0
votes
1 answer

Scala error while resolving overloaded methods

Im getting the following error while trying to use the Play `s Json library for de-serializing json string. I understand it is failing to resolve to an overloaded method but Im failing to understand why? Error:(45, 50) overloaded method value apply…
broun
  • 2,483
  • 5
  • 40
  • 55
0
votes
1 answer

transform an JsArray with play-json

Most of the examples in an json transformer are about JsObject. I try to transform an JsArray but got this error val json = Json.parse("""[{"toto":1},{"toto":10},{"tata":2}]"""] val transformer = (__ \'toto).json.update(__.read[JsNumber].map{o =>…
nam
  • 3,542
  • 9
  • 46
  • 68
0
votes
0 answers

Play json transformers. JsObject to JsObject

I'm expecting JsObject in request body and i want to extract and validate required fields Request Body: { "protoName": "category", "clientId": 2 } My Reads: val userReads: Reads[JsObject] = ( (__ \ "protoName").read[String] ~ (__…
Alexander Kondaurov
  • 3,677
  • 5
  • 42
  • 64
1 2 3
20
21