Render two json objects to the view with Play! scala 2.3
You can use the JsArray
constructor that takes in a Seq[JsValue]
as such:
JsArray(Seq(Json.toJson(obj1), Json.toJson(obj2))
Or if you want to use a JsObject
instead of an array, you can do:
Json.obj("obj1" -> obj1, "obj2" -> obj2)
To merge two objects, you can use ++
:
Json.toJson(obj1).asInstanceOf[JsObject] ++ Json.toJson(obj2).asInstanceOf[JsObject]