static <ENTITY> JsonCollector<ENTITY> toJson(JsonEncoder<ENTITY> encoder) {
        requireNonNull(encoder);
        return JsonCollectorImpl.collect(encoder::apply);
    }
Returns a collector that calls the specified encoder for each element in
the stream and joins the resulting stream separated by commas and
surrounded by square brackets. Each element is also formatted using the
specified {@link JsonEncoder}.

@param <ENTITY> the type of the stream
@param encoder the enocder to use
@return the json string
plugin-parent/json-stream/src/main/java/com/speedment/plugins/json/JsonCollector.java