Details
-
Wish
-
Status: Closed
-
Major
-
Resolution: Fixed
-
None
-
None
Description
Recently I've found myself repetitively doing the following when transforming a stream of simple numerics into a JsonObject (e.g., for publishing via IotDevice(TStream<JsonObject>)):
TStream<Double> s = ... TStream<JsonObject> js = s.map(val -> { JsonObject jo = new JsonObject(); jo.addProperty("propName", val); return jo. });
Unfortunately, addProperty() returns void so the above can't be reduced to something like:
return new JsonObject().addProperty("propName", val)
I'd like an ease-of-use function like:
TStream<JsonObject> js = s.map(JsonFunctions.valueOfNumber("propName"));
For completeness, there should also be valueOfString(), valueOfCharacter(), valueOfBoolean().
Also, JsonAnalytics works with JsonElement partitioned windows: TWindow<JsonObject,JsonElement>. It should be trivial to be able to specify an unpartitioned window. Functions.unpartitioned() provides that for Integer keyed windows. There should be a corresponding JsonFunctions.unpartitioned().