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

use JsLookup for multiple level array using play Json for lists with objects and simple lists

i have a function that exctract from a json list of elements based on the path i give it. the func looks like this: def findAllValuesAtPath(jsValue: JsObject, path: String): List[JsValue] = { val jsPath = JsPath(path .split("\\[\\*]\\.") …
JohnBigs
  • 2,691
  • 3
  • 31
  • 61
1
vote
2 answers

No instance of play.api.libs.json.Format is available for akka.actor.typed.ActorRef[org.knoldus.eventSourcing.UserState.Confirmation]

No instance of play.api.libs.json.Format is available for akka.actor.typed.ActorRef[org.knoldus.eventSourcing.UserState.Confirmation] in the implicit scope (Hint: if declared in the same file, make sure it's declared before) [error] implicit val…
Not_Human
  • 45
  • 4
1
vote
2 answers

Is there a way in Play JSON to define a reader for something that is not an object (/array)?

Basically, I have a JSON of this shape: { "color": "#abcdef" } so I write a Reads: import java.awt.Color case class Options(color: Color) ((__ \ "color").read[Color])(Options _) except there is no reader for Color. My second attempt was: ( …
RubenVerg
  • 145
  • 1
  • 8
1
vote
0 answers

Sealed trait is not supported Play JSON 2.9

I'm attempting to duplicate the test "automatically convert JSON for a sealed family" from ScalaJsonAutomatedSpec.scala in my local environment. However, I'm getting an error: Error:(36, 61) Sealed trait Role is not supported: no known…
Matt
  • 683
  • 1
  • 7
  • 9
1
vote
1 answer

Json body converted to sealed trait

I have a Play! endpoint which can receive a json body as 3 or 4 forms (I tried using generic type, but not working). Controller: def getChartData = Action.async(parse.json) { request => // ERROR: can not cast JsValue to type ChartDataRequest…
AlleXyS
  • 2,476
  • 2
  • 17
  • 37
1
vote
2 answers

How to "reads" into a Scala Case Class given a Json object with key names that start with a capital letter

This question is based upon Scala 2.12.12 scalaVersion := "2.12.12" using play-json "com.typesafe.play" %% "play-json" % "2.9.1" If I have a Json object that looks like this: { "UpperCaseKey": "some value", "AnotherUpperCaseKey": "some…
Techmag
  • 1,383
  • 13
  • 24
1
vote
1 answer

Scala Play Read: How to Flatten Json containing Array of arrays to model

I am looking for a way to define a Reads which allows me to map a JSON containing the following structure: { "offers": [ [ { "id": "1234", (etc.) } ] ] } to model such…
Remo
  • 1,112
  • 2
  • 12
  • 25
1
vote
2 answers

Play Framework JSON automated mapping with custom validation

Hi guys I'm new in the Scala world and I want to create a simple REST API using Play Framework. I'm working on JSON mappings to Case Classes, and I have maybe a stupid question. I have a case class that represents a UserDto (it is used for user…
Mirko Manojlovic
  • 73
  • 1
  • 2
  • 9
1
vote
1 answer

How to get rid of extra escape characters while doing json transformation using scala play framework?

I want to update some of the fields present in a json string and I am using play framework in scala.But when I am updating the json few escape string characters are getting introduced.And I dont want these charcters after the json…
trp86
  • 414
  • 1
  • 7
  • 21
1
vote
1 answer

How to delete Seq[String] from JsObject?

private def updateData( oldData: Seq[Data], authorised: Boolean, removeItemList: Seq[String] ): Seq[Data] = { if (!authorised) { oldData.map { data => val props: Option[JsObject] = data.props.map { props =>…
Laleet
  • 41
  • 4
1
vote
1 answer

Json.writes for sealed trait

How to deserialize a sealed trait. I am using play JSON framework. I have read many post for writing companion object. Does anyone know how to write for Json.writes? sealed trait DataFormat case object JSON extends DataFormat …
Aman
  • 123
  • 1
  • 2
  • 10
1
vote
1 answer

Play Json.writes ignore case class property

I have a property in a case class Foo which I don't want to serialize. However, it's a complicated case class and if possible I'd like to use the automatic Json.writes macro to serialize it. Is it possible to annotate a property in the case class…
Rahil Shah
  • 183
  • 1
  • 4
1
vote
0 answers

Transforming ReactiveMongo JSON with Play JSON

ReactiveMongo's JSON functionality generates objects (JsObject in play-json parlance) rather than scalars for certain MongoDB datatypes like BSONObjectID and BSONDateTime. For example, you get JSON like this: { "_id" : { "$oid" :…
Vidya
  • 29,932
  • 7
  • 42
  • 70
1
vote
1 answer

Scala play json - update all values with the same key

Let's say I have a JsValue in the form: { "businessDetails" : { "name" : "Business", "phoneNumber" : "+44 0808 157 0192" }, "employees" : [ { "name" : "Employee 1", "phoneNumber" : "07700 900 982" }, { …
1
vote
1 answer

JSON quotes make parsing impossible

I'm using play's json libraries to parse json sent to me by javascript. Everything worked fine during initial testing but I have discovered that the various front ends send json values bare or wrapped in quotes. This can change from time to time so…
Steve Gailey
  • 129
  • 1
  • 10