Adding topN query functionality to standard JSON output.