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

Writing custom object JSON as a simple value in Scala (JSON Reads/Writes)

I have a custom data type in Scala: case class GPID(value: Int) { // ... other stuff ... implicit val writesGPID = new Writes[GPID] { def writes(g: GPID): JsValue = { Json.obj( "GPID" -> g.value …
Zaphod
  • 1,387
  • 2
  • 17
  • 33
-1
votes
1 answer

Play Framework, Format[A] vs OFormat[A]

I can't find an explanation in the Play Framework docs. I found this question but now I can't see why will I use Format[A] at all.
idan ahal
  • 707
  • 8
  • 21
-1
votes
2 answers

Scala Play JSON trouble converting List[CaseClass] to Json String

Not sure where I am going wrong with this it is returning error: No Json serializer as JsObject found for type List[QM_Category]. Try to implement an implicit OWrites or OFormat for this type. [error] …
phattyD
  • 205
  • 3
  • 11
-1
votes
1 answer

Scala, Play Framework - "JsUndefined("VALUE1" is not an object)" - is there a better way to deserialise json into Map[String, String]?

I have a Json request body that represents four key-value pairs. I am attempting to deserialise the Json body (a JsValue object) into a Map of Strings, Map[String, String], but I get the following error: "JsUndefined("VALUE1" is not an…
Chris
  • 785
  • 10
  • 24
-1
votes
1 answer

retrieving value from a jsArray in scala

I have this variable in scala with val id: Option[(String, JsValue)]= Some((studentId,{"courseId":"765"})) I want to retrieve that id 765 but I am not able to make it happen. Thank you in advance.
-1
votes
1 answer

Play Json serialize/deserialize mutual recursive

How to serialize and deserialize these structures using Play Json combinators? final case class WriteGroupEntity(label: String, items: Map[String, WriteEntity]) final case class WriteEntity(label: String, propertyType:…
kapranov.anton
  • 423
  • 5
  • 14
-1
votes
1 answer

How can I see how many documents were written & handle errors correctly?

From the documentation I can see that I should be able to use WriteResult.ok, WriteResult.code and WriteResult.n in order to understand errors and the number of updated documents but this isn't working. Here is a sample of what I'm doing (using…
-2
votes
1 answer

How to convert List[String] to List[Object] in Scala

I need to change from one List[String] to List[MyObject] in scala. For example,JSON input is like below employee: { name: "test", employeeBranch: ["CSE", "IT", "ECE"] } Output should be like this, Employee: { Name: "test", …
Senthil
  • 39
  • 3
-2
votes
2 answers

JSON processing in scala

I am in the process of switching from json to avro format and all my unit tests are still expecting json. I can convert the newly avro files to json but the schema is embedded. For example: val j = """{"field1": "someString", "field2":…
fricadelle
  • 511
  • 1
  • 8
  • 26
-2
votes
1 answer

Play JSON Error When Parsing from JSON into Case class

I have a simple case class as below: case class SmartMeterData( dateInterval: SmartMeterDataInterval = HalfHourInterval(), powerUnit: PowerUnit = PowerUnit.KWH, smartMeterId: String, timestamp: String, value: Double ) This…
joesan
  • 13,963
  • 27
  • 95
  • 232
-2
votes
1 answer

Iterate over play jsarray

I am trying to iterate over play JsArray as below for (id <- myJSArray) { val bn = new Person(new IDM(id.asInstanceOf[String])) request.add(bn) } but the above does not works with for each...error is cannot resolve symbol…
HDev007
  • 325
  • 2
  • 6
  • 15
-2
votes
1 answer

How could I properly work with Scala Play Read?

According to this documentation (official): https://www.playframework.com/documentation/2.8.x/ScalaJsonCombinators I have to create a case class, after that I have to create a JsonReader: val nameReads: Reads[String] = (JsPath \…
-2
votes
1 answer

Overloaded method value apply with alternatives with optional type class

I'm trying to parse my case classes to and from JsObject but get hit with an overloaded method error that isn't clear to me. The error message says "overloaded method value apply with alternatives". Here is the reads code: import…
User
  • 168
  • 1
  • 3
  • 19
1 2 3
20
21