-
-
Notifications
You must be signed in to change notification settings - Fork 140
Open
Description
Play JSON Version (2.5.x / etc)
3.0.4
API (Scala / Java / Neither / Both)
Scala
Operating System (Ubuntu 15.10 / MacOS 10.10 / Windows 10)
MacOS
JDK (Oracle 1.8.0_72, OpenJDK 1.8.x, Azul Zing)
openjdk version "17.0.11" 2024-04-16 LTS
OpenJDK Runtime Environment Corretto-17.0.11.9.1 (build 17.0.11+9-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.11.9.1 (build 17.0.11+9-LTS, mixed mode, sharing)
Library Dependencies
None
Expected Behavior
Map.map(...) should be written as a json object
For example, this test should pass
"JsValueWrapper conversion" should {
"convert Map.map(...) to json object, not json array" in {
import Writes._
Json.obj("data" -> Map("key" -> "value").map(identity))
.mustEqual(Json.obj("data" -> Json.obj("key" -> "value")))
}
}Actual Behavior
The above test case fails with output:
[info] - should convert Map.map(...) to json object, not json array *** FAILED *** (2 milliseconds)
[info] {"data":[["key","value"]]} did not equal {"data":{"key":"value"}} (JsonSharedSpec.scala:464)
[info] Analysis:
[info] JsObject(underlying: ImmutableLinkedHashMap("data": [["key","value"]] -> {"key":"value"}))
- This is likely a Scala 2 compiler bug. I have opened a ticket Type inference failure while picking among conversions scala/bug#13102
- Through trial and error, I found that the below signature may work. We can try it if the bug can't be fixed in the compiler
implicit def iterableWrites3[A, I[_]](implicit ev: I[A] <:< Iterable[A], w: Writes[A]): Writes[I[A]]Metadata
Metadata
Assignees
Labels
No labels