@@ -79,7 +79,7 @@ pci | ``pci:[vendor=%04x/name][,device=%04x][,card=%d]`` Select using
JSON OUTPUT
===========
-To parse the JSON as output by the tool the consumer should wrap its entirety into square brackets ([ ]). This will make each sample point a JSON array element and will avoid "Multiple root elements" JSON validation error.
+JSON output will be correctly terminated when the tool cleanly exits, otherwise one square bracket needs to be added before parsing.
LIMITATIONS
===========
@@ -2597,6 +2597,9 @@ int main(int argc, char **argv)
scan_clients(clients, false);
codename = igt_device_get_pretty_name(&card, false);
+ if (output_mode == JSON)
+ printf("[\n");
+
while (!stop_top) {
struct clients *disp_clients;
bool consumed = false;
@@ -2683,6 +2686,9 @@ int main(int argc, char **argv)
usleep(period_us);
}
+ if (output_mode == JSON)
+ printf("]\n");
+
if (clients)
free_clients(clients);