output: json nan values need quoting

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2017-11-07 10:41:53 +00:00
parent 8fe7dc2c03
commit eb7547c742
No known key found for this signature in database
GPG key ID: A9553245FDE9B739

View file

@ -540,14 +540,23 @@ static int output_json(const int print_mac_addreses)
fprintf(outfile, "\"used\":%g, ", shared_p->used);
fprintf(outfile, "\"touched\":%g, ", shared_p->touched);
fprintf(outfile, "\"free\":%g, ", shared_p->available - shared_p->used);
fprintf(outfile, "\"percent\":%g, ", oh.percent);
fprintf(outfile, "\"touch_count\":%g, ", oh.tc);
fprintf(outfile, "\"touch_percent\":%g, ", oh.tcp);
if (config.backups_found == 1) {
fprintf(outfile, "\"backup_count\":%g, ", shared_p->backups);
fprintf(outfile, "\"backup_percent\":%g, ", oh.bup);
}
fprintf(outfile, "\"status\":%d ", oh.status);
if (shared_p->available == 0)
fprintf(outfile, "\"percent\":\"%g\", ", oh.percent);
else
fprintf(outfile, "\"percent\":%g, ", oh.percent);
fprintf(outfile, "\"touch_count\":%g, ", oh.tc);
if (shared_p->available == 0)
fprintf(outfile, "\"touch_percent\":\"%g\", ", oh.tcp);
else
fprintf(outfile, "\"touch_percent\":%g, ", oh.tcp);
if (config.backups_found == 1) {
fprintf(outfile, "\"backup_count\":%g, ", shared_p->backups);
if (shared_p->available == 0)
fprintf(outfile, "\"backup_percent\":\"%g\", ", oh.bup);
else
fprintf(outfile, "\"backup_percent\":%g, ", oh.bup);
}
fprintf(outfile, "\"status\":%d ", oh.status);
if (i + 1 < num_shared_networks)
fprintf(outfile, "},\n");
else