mirror of
https://github.com/kdave/btrfs-progs
synced 2025-01-16 18:51:49 +00:00
btrfs-progs: extend fmt_print_start_group to handle unnamed group
Extends fmt_print_start_group() so it can handle when name argument is NULL. It is useful for printing unnamed array or map. Signed-off-by: Sidong Yang <realwakka@gmail.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
0c6e59e0b2
commit
2e8906829a
@ -186,10 +186,12 @@ void fmt_print_start_group(struct format_ctx *fctx, const char *name,
|
||||
fmt_inc_depth(fctx);
|
||||
fctx->jtype[fctx->depth] = jtype;
|
||||
fctx->memb[fctx->depth] = 0;
|
||||
if (name)
|
||||
printf("\"%s\": ", name);
|
||||
if (jtype == JSON_TYPE_MAP)
|
||||
printf("\"%s\": {", name);
|
||||
putchar('{');
|
||||
else if (jtype == JSON_TYPE_ARRAY)
|
||||
printf("\"%s\": [", name);
|
||||
putchar('[');
|
||||
else
|
||||
fmt_error(fctx);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user