What's the best way to log JSON request and response?
Posted: Sun Jan 14, 2024 10:06 am
Hello everyone,
i used this code below to get string json request and response:
I found that these 2 procedures, yajl_StringifyStr and yajl_copyBufStr made the response time quite slow. For yajl_copyBufStr i have no idea, but for yajl_StringifyStr I try to use another job to handle this in batch, send docNode data to dataq, receive dataq with other job, and process log in that job. Code bellow:
Other job to receive:
But this job got error on yajl_stringifyStr:
Any advice about this? Or how can I use these 2 procedures in separate jobs, but still be able to get the json request and response data that I want? Or what's the best way to log JSON request and response with quicker response time?
Thanks,
Fauzi
i used this code below to get string json request and response:
Code: Select all
D docNode S Like(yajl_val)
D requestBody S 16100A
D responseBody S 16100A
...
docNode = yajl_stdin_load_tree(*on:error);
requestBody = yajl_StringifyStr(docNode);
yajl_genOpen(*Off);
yajl_beginObj();
...
yajl_endObj();
ResponseBody = yajl_copyBufStr();
yajl_writeStdout(stsCode:error);
yajl_genClose();
Code: Select all
D docNode S Like(yajl_val)
D dataDocnode S 16100A Based(docNode)
D requestBody S 16100A
...
docNode = yajl_stdin_load_tree(*on:error);
SendDTAQ(dataqName:dataqLib:dataqLength:dataDocnode);
Code: Select all
D docNode S Like(yajl_val)
D dataDocnode S 16100A
D requestBody S 16100A
...
ReceiveDTAQ(dataqName:dataqLib:dataqLength:dataDocnode:waitTime);
docNode = %Addr(dataDocnode);
requestBody = yajl_stringifyStr(docNode);
Code: Select all
Pointer not set for location referenced.
Unmonitored exception at statement 5223 of procedure GENFROMNODE
Thanks,
Fauzi