ANALYZE FORMAT=JSON: better output and tests

- Print r_loops
- Always print r_* members. Print NULL values if no scans took place
- Added testcases.