I have a simple cobol program that currently receives a json payload from another cobol program (via an API type call). We have a need for a C++ program to be able to pass the same json string to the cobol program via the existing api calling method (currently oracle tuxedo).
I have a working cpp client and its json is structured correctly, the json it pretty simple and is along the lines of the following:
{ "APICALL": {"APINAME":"DUMMYAPI", "APIPARAMS": {"PARM1":"VALUE1", "PARM2": "VALUE2"}}}
The cobol program that is receiving the API call needs to extract the APINAME and pass the APIPARAMS string when calling the cobol module named in "APINAME".
I need to be able to just pass the value of APIPARAMS on, if I have something like the following defined:
01 API-CALL.
03 API-NAME PIC X(30).
03 API-PARAMS PIC X(400).
If I "JSON PARSE" it I end up with binary "junk" in API_PARAMS (API-NAME is spot on) in my cobol program, unless I call if from another cobol program. When that happens it appears that cobol is putting "\" in string for APIPARAMS around the quotes and works. I understand why it should work as its just a quoted string at that point, however my Cpp code uses a web framework so it creating a proper json input as seen above, ie no backslashes.
Question is how do I get the "string" side of API_PARAMS via JSON PARSE or is it not possible? I know I can define the elements in API_PARAMS and that works, but I don't need to access the params individually, plus they might be different for different calls. In fact my COBOL program is pretty agnostic and just needs to pass the json string (I know its not technically a string, its a map) to the next module it calls. It then returns the results back to the calling system, essentially its just a simple pass through interface.
I apologise in advance as I'm not a cobol programmer and haven't done cobol for decades so my terminology etc might be off, but I've googled till I'm running out of the will to live. Initially I thought it was my cpp program that was sending in duff data but its actually correct, it seems to be how COBOL does or doesn't allow the dumping of the whole of the JSON Map "API_PARAMS".
Thanks in advance