Skip to content

Commit 9a289ac

Browse files
committed
printer json FEATURE no namespace for inner nodes
1 parent 7479100 commit 9a289ac

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/printer_json.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ json_print_member(struct jsonpr_ctx *pctx, const struct lyd_node *node, const st
307307
}
308308

309309
PRINT_COMMA;
310-
if ((LEVEL == 1) || json_nscmp(node, snode, pctx->parent)) {
310+
if (json_nscmp(node, snode, pctx->parent)) {
311311
/* print "namespace" */
312312
node_prefix(node, snode, &pref, NULL);
313313
ly_print_(pctx->out, "%*s\"%s%s:%s\":%s", INDENT, is_attr ? "@" : "", pref, name, DO_FORMAT ? " " : "");
@@ -1162,7 +1162,6 @@ json_print_data(struct ly_out *out, const struct lyd_node *root, uint32_t option
11621162
}
11631163

11641164
pctx.out = out;
1165-
pctx.parent = NULL;
11661165
pctx.level = 1;
11671166
pctx.level_printed = 0;
11681167
pctx.options = options;
@@ -1174,6 +1173,7 @@ json_print_data(struct ly_out *out, const struct lyd_node *root, uint32_t option
11741173
/* content */
11751174
LY_LIST_FOR(root, node) {
11761175
pctx.root = node;
1176+
pctx.parent = (const struct lyd_node *)(node->parent);
11771177
LY_CHECK_RET(json_print_node(&pctx, node));
11781178
if (!(options & LYD_PRINT_SIBLINGS)) {
11791179
break;

tests/utests/data/test_parser_json.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ test_baretop_leaf(void **state)
9999
fail_msg("Print err 0x%d; MSG: %s", ret, ly_err_last(UTEST_LYCTX)->msg);
100100
}
101101

102-
CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_WITHSIBLINGS, exp_str_sib[i]);
102+
CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_SIBLINGS, exp_str_sib[i]);
103103
lyd_free_all(tree);
104104
ly_in_free(in, 0);
105105
}
@@ -863,7 +863,7 @@ test_reply(void **state)
863863
CHECK_LYSC_NODE(tree->schema, NULL, 0, LYS_CONFIG_W | LYS_STATUS_CURR, 1, "c", 1, LYS_CONTAINER, 0, 0, NULL, 0);
864864

865865
/* TODO print only rpc-reply node and then output subtree */
866-
CHECK_LYD_STRING(lyd_child(op), LYD_PRINT_SHRINK | LYD_PRINT_SIBLINGS, "{\"a:al\":25}");
866+
CHECK_LYD_STRING(lyd_child(op), LYD_PRINT_SHRINK | LYD_PRINT_SIBLINGS, "{\"al\":25}");
867867
CHECK_LYD_STRING(tree, LYD_PRINT_SHRINK | LYD_PRINT_SIBLINGS, "{\"a:c\":{\"act\":{\"al\":25}}}");
868868
lyd_free_all(tree);
869869

0 commit comments

Comments
 (0)