0
0
Fork 0
mirror of https://github.com/netdata/netdata.git synced 2025-03-16 22:13:38 +00:00

allow parsing empty json arrays and objects ()

This commit is contained in:
Costa Tsaousis 2025-02-20 16:28:34 +02:00 committed by Austin S. Hemmelgarn
parent 0f343f8e54
commit 94f24b6b52
No known key found for this signature in database
GPG key ID: 2C02F9340D33625A

View file

@ -513,6 +513,12 @@ static inline bool json_parse_array(LOG_JSON_STATE *js) {
size_t index = 0;
do {
const char *s = json_current_pos(js);
if(*s == ']') {
json_consume_char(js);
break;
}
if(!json_key_index_and_push(js, index))
return false;
@ -524,7 +530,7 @@ static inline bool json_parse_array(LOG_JSON_STATE *js) {
if(!json_expect_char_after_white_space(js, ",]"))
return false;
const char *s = json_current_pos(js);
s = json_current_pos(js);
json_consume_char(js);
if(*s == ',') {
index++;
@ -545,6 +551,12 @@ static inline bool json_parse_object(LOG_JSON_STATE *js) {
json_consume_char(js);
do {
const char *s = json_current_pos(js);
if(*s == '}') {
json_consume_char(js);
break;
}
if (!json_expect_char_after_white_space(js, "\""))
return false;
@ -564,7 +576,7 @@ static inline bool json_parse_object(LOG_JSON_STATE *js) {
if(!json_expect_char_after_white_space(js, ",}"))
return false;
const char *s = json_current_pos(js);
s = json_current_pos(js);
json_consume_char(js);
if(*s == ',')
continue;