@ -697,6 +697,8 @@ static void prepare_resp_ctx(ng_command_ctx_t *command_ctx, const ng_parser_t *p
/* init as dict by default, if requested */
if ( native )
parser - > init ( & command_ctx - > parser_ctx , & command_ctx - > ngbuf - > buffer ) ;
/* TODO: JSON-like structured data probably needs to have own `parser_arg`
* because otherwise resp is always added as dictionary */
command_ctx - > resp = parser - > dict ( & command_ctx - > parser_ctx ) ;
assert ( command_ctx - > resp . gen ! = NULL ) ;
}
@ -740,13 +742,13 @@ static void control_ng_process_payload(ng_ctx *hctx, str *reply, str *data, cons
command_ctx . ngbuf - > json = json_parser_new ( ) ;
errstr = " Failed to parse JSON document " ;
if ( ! json_parser_load_from_data ( command_ctx . ngbuf - > json , data - > s , data - > len , NULL ) ) {
prepare_resp_ctx ( & command_ctx , parser, false ) ;
prepare_resp_ctx ( & command_ctx , json_ parser, false ) ;
goto err_send ;
}
command_ctx . req . json = json_parser_get_root ( command_ctx . ngbuf - > json ) ;
errstr = " Could not decode JSON dictionary " ;
if ( ! command_ctx . req . json | | ! json_parser - > is_dict ( command_ctx . req ) ) {
prepare_resp_ctx ( & command_ctx , parser, false ) ;
prepare_resp_ctx ( & command_ctx , json_ parser, false ) ;
goto err_send ;
}
}
@ -759,6 +761,8 @@ static void control_ng_process_payload(ng_ctx *hctx, str *reply, str *data, cons
parser = command_ctx . parser_ctx . parser ;
/* TODO: JSON-like structured data probably needs to have own `parser_arg`
* because otherwise resp is always added as dictionary */
command_ctx . resp = parser - > dict ( & command_ctx . parser_ctx ) ;
assert ( command_ctx . resp . gen ! = NULL ) ;