@@ -234,9 +234,8 @@ show_instance_start(void)
234
234
first_instance = true;
235
235
json_level = 0 ;
236
236
237
- json_add (& show_buf , JT_BEGIN_OBJECT );
238
- json_add_key (& show_buf , "instances" , false);
239
- json_add (& show_buf , JT_BEGIN_ARRAY );
237
+ appendPQExpBufferChar (& show_buf , '[' );
238
+ json_level ++ ;
240
239
}
241
240
242
241
/*
@@ -246,11 +245,7 @@ static void
246
245
show_instance_end (void )
247
246
{
248
247
if (show_format == SHOW_JSON )
249
- {
250
- json_add (& show_buf , JT_END_ARRAY );
251
- json_add (& show_buf , JT_END_OBJECT );
252
- appendPQExpBufferChar (& show_buf , '\n' );
253
- }
248
+ appendPQExpBufferStr (& show_buf , "\n]\n" );
254
249
255
250
fputs (show_buf .data , stdout );
256
251
termPQExpBuffer (& show_buf );
@@ -505,10 +500,9 @@ show_instance_json(parray *backup_list)
505
500
506
501
/* Begin of instance object */
507
502
json_add (buf , JT_BEGIN_OBJECT );
508
- json_add_key (buf , instance_name , false);
509
503
510
- json_add (buf , JT_BEGIN_OBJECT );
511
- json_add_key (buf , "backups" , false );
504
+ json_add_value (buf , "instance" , instance_name , false );
505
+ json_add_key (buf , "backups" , true );
512
506
513
507
/*
514
508
* List backups.
@@ -528,19 +522,14 @@ show_instance_json(parray *backup_list)
528
522
appendPQExpBufferChar (buf , ',' );
529
523
530
524
json_add (buf , JT_BEGIN_OBJECT );
531
- json_add_key (buf , base36enc (backup -> start_time ), false);
532
525
533
- /* Show backup attributes */
534
- json_add (buf , JT_BEGIN_OBJECT );
526
+ json_add_value (buf , "id" , base36enc (backup -> start_time ), false);
535
527
536
528
if (backup -> parent_backup != 0 )
537
- {
538
529
json_add_value (buf , "parent-backup-id" ,
539
- base36enc (backup -> parent_backup ), false);
540
- json_add_value (buf , "backup-mode" , pgBackupGetBackupMode (backup ), true);
541
- }
542
- else
543
- json_add_value (buf , "backup-mode" , pgBackupGetBackupMode (backup ), false);
530
+ base36enc (backup -> parent_backup ), true);
531
+
532
+ json_add_value (buf , "backup-mode" , pgBackupGetBackupMode (backup ), true);
544
533
545
534
json_add_value (buf , "wal" , backup -> stream ? "STREAM" : "ARCHIVE" , true);
546
535
@@ -612,15 +601,11 @@ show_instance_json(parray *backup_list)
612
601
613
602
json_add_value (buf , "status" , status2str (backup -> status ), true);
614
603
615
- json_add (buf , JT_END_OBJECT );
616
- /* End of backup attributes */
617
-
618
604
json_add (buf , JT_END_OBJECT );
619
605
}
620
606
621
607
/* End of backups */
622
608
json_add (buf , JT_END_ARRAY );
623
- json_add (buf , JT_END_OBJECT );
624
609
625
610
/* End of instance object */
626
611
json_add (buf , JT_END_OBJECT );
0 commit comments