2016 Jun 24 2:34 PM
Hello Together,
Is it possible to read a complex json Response with simple Transformation?
I've found some example coding to create and read JSON with XMLReader and XMLWriter in combination with simpel Transformation.
With a small structure it works very fine. But if I working with a big json Response with nested child structures that are not obligatory. I have big Problems to create a working ST.
Best Regards
Uwe
2016 Jun 24 4:40 PM
I think that it's the same issue as with XML. You have to specify those elements which are optional (tt:d-cond, etc.)
(and make sure you have applied SAP corrections in case of bugs).
2016 Jun 24 4:40 PM
I think that it's the same issue as with XML. You have to specify those elements which are optional (tt:d-cond, etc.)
(and make sure you have applied SAP corrections in case of bugs).
2016 Jun 27 7:48 AM
I've allready made some test with conditions but I'm not able to create a running ST.
The Problem is that I have optional Array data: artAttributes (see attached File (it is allready the XML representation of JSON))
I have the following ST:
<tt:d-cond check="exist(artAttributesI">
<object>
...
</object>
</tt:d-cond>
But the condition in both cases true.
Maybe I have an error with the condition?
2016 Jun 27 8:14 AM
(that's not the issue but typo in check="exist(artAttributesI" -> check="exist(artAttributes)")
Edit: I looked at your artData.xml, and I think you're right, it's not possible to condition an element based on one of its attributes ("name" here). And you can't either condition its inner element "array" as it's also used for other values of this attribute. So I think you need to exclude the values via ABAP code only, after the transformation.
2016 Jun 27 9:21 AM
Hello Sandra,
Thank you for your Response.
Because artDescription is an attribute I have to use the following code:
<tt:d-cond>
<object Name="artDescription">
...
</object>
</tt:d-cond>
But now I've understand what is ment with patern in the SAP docu for Simple Transformation conditions.
best regards
2016 Jun 27 9:53 AM
Thanks for the feedback. So, my answer was mostly incorrect (only my remark about "check" was correct, but my remark about "it's not possible to condition an element based on one of its attributes" was wrong, as I thought <object Name="artDescription"> couldn't work).
Please, mark your own answer as correct, to not mislead forum readers.
2016 Jun 25 10:25 AM
We started off by using CL_XI_ALERT_JSON_DOCUMENT.
We ended up copying that Class and changing it as it didn't escape characters that well.