Backport of pr/267, [GEOS-6088] Add support for count in json output