Play Framework – add a field to JSON object

JsObject has a + method that allows you to add fields to an object, but unfortunately your jsonObject is statically typed as a JsValue, not a JsObject. You can get around this in a couple of ways. The first is to use as: scala> jsonObject.as[JsObject] + (“c” -> Json.toJson(3)) res0: play.api.libs.json.JsObject = {“a”:1,”b”:2,”c”:3} With as … Read more

Discovery of Akka actors in cluster

I’m working on a private project which is basically a very extended version of the chatroom example and I also had startup problems with akka and the whole “decentralized” thinking. So I can tell you how I “solved” my extended chatroom: I wanted a server which could easily be deployed multiple times without much additional … Read more

NodeJS vs Play Framework for large project

The stack you choose should depend upon the needs of your application. Let’s look at Play vs. Node for their strengths: Node Real-time applications (chat, feeds) Event-driven architecture Can perform client-server duties (e.g. serve files), but not well-suited for this Database management, testing tools, etc, available as additional packages Play! Client-server applications (website, services) Share-nothing … Read more

Noise free JSON format for sealed traits with Play 2.2 library

AMENDED 2015-09-22 The library play-json-extra includes the play-json-variants strategy, but also the [play-json-extensions] strategy (flat string for case objects mixed with objects for case classes no extra $variant or $type unless needed). It also provides serializers and deserializers for macramé based enums. Previous answer There is now a library called play-json-variants which allows you to … Read more

What is the difference between ‘CompletionStage’ and ‘CompletableFuture’

CompletionStage<T> is an interface of which CompletableFuture<T> is the only current implementing class. By looking at the javadoc for CompletionStage<T>, you’ll notice it provides methods for taking one CompletionStage<T> and transforming it into another CompletionStage<T>. However, the returned values by the CompletionStage<T> are actually themselves CompletabeFuture<T> objects. So using CompletabeFuture<T> is kind of the same … Read more