4 weeks ago - last edited 4 weeks ago
We are calling a service where where we can get get varying JSON payload responses, and then processing the response with the XCO library (xco_cp_json=>data->from_string).
The outer part is common, but the inside can be different. For example:
{
"data": {
"items": [
{
// At this level, there are different fields depending on the call
}
]
}
}
I would like to get access to the list/table of entities inside the "items" element and forward that to a method that will handle the specific data depending on the situation.
So I would like to define a structure type to handle this, e.g.
TYPES: BEGIN OF json_payload,
BEGIN OF data,
items TYPE ???, "<- what to use here?
[ OR ]
items TYPE TABLE OF ???, "<- what to use here?
END OF data,
END OF json_payload.
I am sure that one of the previous JSON libraries I used (perhaps it was my own) allowed me to specify a TYPE REF to a JSON node (e.g. CL_JSON_NODE) and after the deserialization, that would contain a reference to that portion of the JSON document that could then be processed further.
Any ideas on how to handle this kind of situation with XCO?
Request clarification before answering.
Hi, Is there a reasen that you aren't using the class /UI2/CL_JSON? I don't know the class you are using but I think you can assign the returning parameter with the inline declaration? When I am facing such problems I use the classes cl_abap_datadescr, cl_abap_tabledescr... and so on. This allows me to resolve and assign the structures recursively so I can access them. I hope that helps!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
73 | |
18 | |
9 | |
8 | |
7 | |
4 | |
4 | |
4 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.