Skip to content

Commit

Permalink
Added final \n to JSON pretty-print output
Browse files Browse the repository at this point in the history
This was a correction of fix to: [CLI Show config JSON with multiple top-level elements is broken](#381)
  • Loading branch information
olofhagsand committed Oct 29, 2022
1 parent 83f7152 commit c93f264
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 14 deletions.
11 changes: 0 additions & 11 deletions apps/cli/cli_show.c
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,6 @@ cli_show_common(clicon_handle h,
cxobj **vec = NULL;
size_t veclen;
cxobj *xp;
yang_stmt *yp;
enum rfc_6020 ys_keyword;
int i;

if (state && strcmp(db, "running") != 0){
Expand Down Expand Up @@ -471,11 +469,6 @@ cli_show_common(clicon_handle h,
if (xpath_vec(xt, nsc, "%s", &vec, &veclen, xpath) < 0)
goto done;
if (veclen){
xp = vec[0]; /* First peek to see if it is special case yang list */
if ((yp = xml_spec(xp)) != NULL)
ys_keyword = yang_keyword_get(xml_spec(xp));
else
ys_keyword = 0;
/* Special case LIST */
if (format == FORMAT_JSON){
switch (format){
Expand All @@ -490,10 +483,6 @@ cli_show_common(clicon_handle h,
else /* Default */
for (i=0; i<veclen; i++){
xp = vec[i];
if ((yp = xml_spec(xp)) != NULL)
ys_keyword = yang_keyword_get(xml_spec(xp));
else
ys_keyword = 0;
/* Print configuration according to format */
switch (format){
case FORMAT_XML:
Expand Down
4 changes: 1 addition & 3 deletions lib/src/clixon_json.c
Original file line number Diff line number Diff line change
Expand Up @@ -1344,9 +1344,7 @@ xml2json_vec(FILE *f,
}
if (xml2json_cbuf_vec(cb, vec, veclen, pretty, skiptop) < 0)
goto done;
fprintf(f, "%s", cbuf_get(cb));
if (!pretty)
fprintf(f, "\n");
fprintf(f, "%s\n", cbuf_get(cb));
retval = 0;
done:
if (cb)
Expand Down

0 comments on commit c93f264

Please sign in to comment.