@@ -697,6 +697,12 @@ iperf_set_test_json_stream(struct iperf_test *ipt, int json_stream)
697697 ipt -> json_stream = json_stream ;
698698}
699699
700+ void
701+ iperf_set_test_json_stream_full_output ( struct iperf_test * ipt , int json_stream_full_output )
702+ {
703+ ipt -> json_stream_full_output = json_stream_full_output ;
704+ }
705+
700706void
701707iperf_set_test_json_callback (struct iperf_test * ipt , void (* callback )(struct iperf_test * , char * ))
702708{
@@ -1089,6 +1095,7 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
10891095 {"verbose" , no_argument , NULL , 'V' },
10901096 {"json" , no_argument , NULL , 'J' },
10911097 {"json-stream" , no_argument , NULL , OPT_JSON_STREAM },
1098+ {"json-stream-full-output" , no_argument , NULL , OPT_JSON_STREAM_FULL_OUTPUT },
10921099 {"version" , no_argument , NULL , 'v' },
10931100 {"server" , no_argument , NULL , 's' },
10941101 {"client" , required_argument , NULL , 'c' },
@@ -1255,6 +1262,9 @@ iperf_parse_arguments(struct iperf_test *test, int argc, char **argv)
12551262 test -> json_output = 1 ;
12561263 test -> json_stream = 1 ;
12571264 break ;
1265+ case OPT_JSON_STREAM_FULL_OUTPUT :
1266+ test -> json_stream_full_output = 1 ;
1267+ break ;
12581268 case 'v' :
12591269 printf ("%s (cJSON %s)\n%s\n%s\n" , version , cJSON_Version (), get_system_info (),
12601270 get_optional_features ());
@@ -3724,7 +3734,7 @@ iperf_print_intermediate(struct iperf_test *test)
37243734 *
37253735 * This avoids unneeded memory build up for long sessions.
37263736 */
3727- discard_json = test -> json_stream == 1 && !(test -> role == 's' && test -> get_server_output );
3737+ discard_json = ! test -> json_stream_full_output && test -> json_stream == 1 && !(test -> role == 's' && test -> get_server_output );
37283738
37293739 if (test -> json_output ) {
37303740 json_interval = cJSON_CreateObject ();
@@ -5116,6 +5126,8 @@ iperf_json_finish(struct iperf_test *test)
51165126 cJSON_AddStringToObject (test -> json_top , "server_output_text" , test -> server_output_text );
51175127 }
51185128
5129+ int print_full_json = 1 ;
5130+
51195131 /* --json-stream, so we print various individual objects */
51205132 if (test -> json_stream ) {
51215133 cJSON * error = iperf_cJSON_GetObjectItemType (test -> json_top , "error" , cJSON_String );
@@ -5129,9 +5141,12 @@ iperf_json_finish(struct iperf_test *test)
51295141 JSONStream_Output (test , "server_output_text" , cJSON_CreateString (test -> server_output_text ));
51305142 }
51315143 JSONStream_Output (test , "end" , test -> json_end );
5144+
5145+ if (!test -> json_stream_full_output )
5146+ print_full_json = 0 ;
51325147 }
51335148 /* Original --json output, single monolithic object */
5134- else {
5149+ if ( print_full_json ) {
51355150 /*
51365151 * Get ASCII rendering of JSON structure. Then make our
51375152 * own copy of it and return the storage that cJSON
0 commit comments