summaryrefslogtreecommitdiff
path: root/strings/json_lib.c
diff options
context:
space:
mode:
Diffstat (limited to 'strings/json_lib.c')
-rw-r--r--strings/json_lib.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/strings/json_lib.c b/strings/json_lib.c
index 139bd98742f..2b764e8827e 100644
--- a/strings/json_lib.c
+++ b/strings/json_lib.c
@@ -1195,6 +1195,27 @@ int json_skip_to_level(json_engine_t *j, int level)
}
+/*
+ works as json_skip_level() but also counts items on the current
+ level skipped.
+*/
+int json_skip_level_and_count(json_engine_t *j, int *n_items_skipped)
+{
+ int level= j->stack_p;
+
+ *n_items_skipped= 0;
+ while (json_scan_next(j) == 0)
+ {
+ if (j->stack_p < level)
+ return 0;
+ if (j->stack_p == level && j->state == JST_VALUE)
+ (*n_items_skipped)++;
+ }
+
+ return 1;
+}
+
+
int json_skip_key(json_engine_t *j)
{
if (json_read_value(j))