diff --git a/src/collectors/log2journal/log2journal-json.c b/src/collectors/log2journal/log2journal-json.c
index be369ffe99..9a3068911e 100644
--- a/src/collectors/log2journal/log2journal-json.c
+++ b/src/collectors/log2journal/log2journal-json.c
@@ -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;