Skip to content

Commit fcb2a58

Browse files
committed
JSON output: remove quotation marks around numerical values if detailed or template info is enabled
1 parent 1def882 commit fcb2a58

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/plugins/output/json/src/Storage.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -181,10 +181,10 @@ Storage::convert_tmplt_rec(struct fds_tset_iter *tset_iter, uint16_t set_id, fds
181181

182182
// Printing out the header
183183
char field[LOCAL_BSIZE];
184-
snprintf(field, LOCAL_BSIZE, "\"ipfix:templateId\":\"%" PRIu16 "\"", tmplt->id);
184+
snprintf(field, LOCAL_BSIZE, "\"ipfix:templateId\":%" PRIu16, tmplt->id);
185185
buffer_append(field);
186186
if (set_id == FDS_IPFIX_SET_OPTS_TMPLT) {
187-
snprintf(field, LOCAL_BSIZE, ",\"ipfix:scopeCount\":\"%" PRIu16 "\"", tmplt->fields_cnt_scope);
187+
snprintf(field, LOCAL_BSIZE, ",\"ipfix:scopeCount\":%" PRIu16, tmplt->fields_cnt_scope);
188188
buffer_append(field);
189189
}
190190

@@ -202,11 +202,11 @@ Storage::convert_tmplt_rec(struct fds_tset_iter *tset_iter, uint16_t set_id, fds
202202
buffer_append(",");
203203
}
204204
buffer_append("{");
205-
snprintf(field, LOCAL_BSIZE, "\"ipfix:elementId\":\"%" PRIu16 "\"", current.id);
205+
snprintf(field, LOCAL_BSIZE, "\"ipfix:elementId\":%" PRIu16, current.id);
206206
buffer_append(field);
207-
snprintf(field, LOCAL_BSIZE, ",\"ipfix:enterpriseId\":\"%" PRIu32 "\"", current.en);
207+
snprintf(field, LOCAL_BSIZE, ",\"ipfix:enterpriseId\":%" PRIu32, current.en);
208208
buffer_append(field);
209-
snprintf(field, LOCAL_BSIZE, ",\"ipfix:fieldLength\":\"%" PRIu16 "\"", current.length);
209+
snprintf(field, LOCAL_BSIZE, ",\"ipfix:fieldLength\":%" PRIu16, current.length);
210210
buffer_append(field);
211211
buffer_append("}");
212212
}
@@ -346,16 +346,16 @@ Storage::addDetailedInfo(fds_ipfix_msg_hdr *hdr)
346346
{
347347
// Array for formatting detailed info fields
348348
char field[LOCAL_BSIZE];
349-
snprintf(field, LOCAL_BSIZE, ",\"ipfix:exportTime\":\"%" PRIu32 "\"", ntohl(hdr->export_time));
349+
snprintf(field, LOCAL_BSIZE, ",\"ipfix:exportTime\":%" PRIu32, ntohl(hdr->export_time));
350350
buffer_append(field);
351351

352-
snprintf(field, LOCAL_BSIZE, ",\"ipfix:seqNumber\":\"%" PRIu32 "\"", ntohl(hdr->seq_num));
352+
snprintf(field, LOCAL_BSIZE, ",\"ipfix:seqNumber\":%" PRIu32, ntohl(hdr->seq_num));
353353
buffer_append(field);
354354

355-
snprintf(field, LOCAL_BSIZE, ",\"ipfix:odid\":\"%" PRIu32 "\"", ntohl(hdr->odid));
355+
snprintf(field, LOCAL_BSIZE, ",\"ipfix:odid\":%" PRIu32, ntohl(hdr->odid));
356356
buffer_append(field);
357357

358-
snprintf(field, LOCAL_BSIZE, ",\"ipfix:msgLength\":\"%" PRIu16 "\"", ntohs(hdr->length));
358+
snprintf(field, LOCAL_BSIZE, ",\"ipfix:msgLength\":%" PRIu16, ntohs(hdr->length));
359359
buffer_append(field);
360360
}
361361

@@ -392,7 +392,7 @@ Storage::convert(struct fds_drec &rec, const fds_iemgr_t *iemgr, fds_ipfix_msg_h
392392

393393
// Add template ID to JSON string
394394
char field[LOCAL_BSIZE];
395-
snprintf(field, LOCAL_BSIZE, ",\"ipfix:templateId\":\"%" PRIu16 "\"", rec.tmplt->id);
395+
snprintf(field, LOCAL_BSIZE, ",\"ipfix:templateId\":%" PRIu16, rec.tmplt->id);
396396
buffer_append(field);
397397

398398
// Append the record with '}' parenthesis removed before

0 commit comments

Comments
 (0)