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

Recursive tranformer in play json

I want to update all objects in jsValue by applying transformer import play.api.libs.json._ val json = Json.obj( "whatever" -> 1, "content" -> "hello world", "sub" -> Json.obj("content" -> "love world" )) val transformer = (__ \\…
Alexander Kondaurov
  • 3,677
  • 5
  • 42
  • 64
0
votes
1 answer

Play JSON serialize/deserialize case class with one argument by skipping it

I have the following objects: case class Foo(value: UUID) case class Bar(foo: Foo) And I would like to have them serialized like this in JSON: {foo: "e88ad5ea-13cf-4666-addb-c231c12cd3a3"} Meaning I want to omit the "value" argument added by the…
CanardMoussant
  • 913
  • 8
  • 22
0
votes
1 answer

Get a Json format for a Seq of a generic type

I have an abstract class with a generic type which gets a Json format for that generic type from its subclass. But the abstract class also needs a Json format of a sequence of that type. Is there any way in Scala to get a Json format of a sequence…
David ten Hove
  • 2,748
  • 18
  • 33
0
votes
1 answer

Install Play 2.4.4

How to install Play 2.4.4 framework on mac?
0
votes
1 answer

How can I programmatically create a validation contract at compile-time?

I apologize in advance if this is an XY problem. tl;dr: I'd like to have a compile-time map of type [Request.type, Response.type] so I can effectively say if I send message Request, a CLI should, at compile-time, know how to deserialize its expected…
erip
  • 16,374
  • 11
  • 66
  • 121
0
votes
1 answer

How can I parse an object of a bounded type T from JSON from an implicit request?

I have some simple messages with implicit Json.reads and Json.formats defined in their companion objects. All of these messages extend MyBaseMessage. In other words, for any T <: MyBaseMessage, T is (de)serializable. These messages represent…
erip
  • 16,374
  • 11
  • 66
  • 121
0
votes
1 answer

Build error using Scala play-json JsValue.as to parse string

I'm using scala play-json to parse the keys from a simple json object from a string along the lines of '{"test": "value", "hello": "world"}' The code where I'm doing this looks like this: val columns = Json.parse(value).as[JsObject].keys.toList I…
0
votes
1 answer

Create Json from scala object with List

I need to create a Json with 2 elements. The First element is a List and the second element is simple key-value pair. My output looks as follows: "{ "tables":[ {"table": "sn: 2134"}, {"table": "sn: 5676"}, {"table": "sn: 4564"}, ], …
Alok
  • 1,374
  • 3
  • 18
  • 44
0
votes
1 answer

Play JSON JsPath Conditional Types

I receive JSON response from an upstream server that I do not have a control on, for modification. The JSON could have the following format {"data":[["Some_text","boolean",["key_string1","key_string2"]]]} Or it could also show up…
Serendipity
  • 1,015
  • 1
  • 10
  • 19
0
votes
2 answers

formatters for List[DateTime] play scala

I am working on a project using Play, Scala, MongoDB. I want to store the List[Datetime] in a collection, so I need fomatters for it. To store the Datetime I used this formatter implicit def dateFormat = { val dateStandardFormat =…
Kiran Sunkari
  • 301
  • 1
  • 3
  • 15
0
votes
0 answers

Transforming the json data using scala to look like a normalized output

I have an input json which is read from a denormalized table. In my scala application, I need to normalize it before returning the resultset. If below is the sample input: inputJson = { "k1": "v0", "k2": [{ "k21": [ …
Gayatri Mahesh
  • 327
  • 1
  • 3
  • 12
0
votes
1 answer

Generate case classes serializer and deserializer implicitly using play-json

I'm using play-json to map Json to case classes or enums. I'm looking for a smart way of creating Formats implicitly, since my project contains many types definitions. At the moment I created a simple function to generate Formats for Enums: def…
WalkerTR
  • 23
  • 5
0
votes
0 answers

How to include case class body members in Play Json Writes?

I have: sealed trait MessageType { def description: String } object MessageType { case object Important extends MessageType { override val description = "important" } case object Normal extends MessageType { override val description = "normal"…
Shafique Jamal
  • 1,550
  • 3
  • 21
  • 45
0
votes
1 answer

Could someone explain how is the this code executing?

How is the createUser or updateUser using the unmarshalValueJs function and passing arguments. package controllers.user import play.api._ import play.api.mvc._ import play.api.libs.json._ import play.api.libs.json.Reads._ import…
toddler
  • 45
  • 5
0
votes
2 answers

Play JSON Read Error When Reading a Sequence

I have the following case class: case class VirtualAssetConfigParam( id: Long, pMin: Double, pMax: Double, dispatchPriority: Int ) object VirtualAssetConfigParam { implicit val virtualAssetConfigParamReads: Reads[VirtualAssetConfigParam]…
joesan
  • 13,963
  • 27
  • 95
  • 232