Hi Folks,
hoping that Sandra Rossi will pick this up, but hey, maybe someone else will have an answer.
I have an incoming JSON structure to transform into ABAP; so far, so good. Unfortunately, the JSON content is inconsistent. I have learned how to deal with occasional null values using this technique in the transformation:
<tt:cond>
<num name="ewbno">
<tt:value ref="einvoice_response.results.message.ewbno"/>
</num>
</tt:cond>
<tt:cond>
<null name="ewbno">
<tt:value ref="einvoice_response.results.message.ewbno"/>
</null>
</tt:cond>
<tt:cond>
However, I there is another issue; I'm hoping that one of the ST commands will solve it, but the ABAP keyword help isn't very detailed. The problem is this: is there any way to deal with a key pair in the JSON string that might not even be present? So the JSON structure might look like this:
{
"QRCodeUrl": "https://sandb-api..../",
"EinvoicePdf": "https://sandb-api..../",
"EwaybillPdf": "https://sandb-api..../",
"Status": "ACT",
"Remarks": ""
}
Or it might look like this:
{
"QRCodeUrl": "https://sandb-api..../",
"EinvoicePdf": "https://sandb-api..../",
"Status": "ACT",
"Remarks": ""
}
Furthermore, the (external) API programming team who produce this stuff are not about to play ball. I'm stuck with it.
There is an obvious workaround of course: I could just use two almost identical transformations, and search the incoming string for 'EwaybillPdf', then process accordingly.
But I'm hoping there is a more elegant solution.
Thank you for reading,
John M.