2023 Jan 15 9:20 AM
Hello All,
I am using mthod cl_fdt_json=>json_to_data to convert my json response to abap structure but i am not getting data back in abap structure . below is the json response and the abap structure. please help to identify the issue? its urgent.
{
"destination_addresses" : [ "Zeppelinstraße 100, 73730 Esslingen am Neckar, Germany" ],
"origin_addresses" : [ "Auf d. Rut 4, 64668 Rimbach, Germany" ],
"rows" : [
{
"elements" : [
{
"distance" : {
"text" : "171 km",
"value" : 171307
},
"duration" : {
"text" : "2 hours 6 mins",
"value" : 7581
},
"status" : "OK"
}
]
}
],
"status" : "OK"
}
2023 Jan 15 1:07 PM
In JSON, square brackets mean tables, but you defined structures in ABAP instead of table types...
NB: I agree with Manfred that you'd better create "a self contained test program which takes the JSON string as constant input and then trying the remaining decoding." It's also the way I troubleshoot issues and this way it's more easy to ask people to look at my issue if I can't find a solution myself.
2023 Jan 15 9:30 AM
Would be great if you also provided the ABAP type part and the API call portion as source code of a self contained test program rather than bitmaps.
2023 Jan 15 9:38 AM
hi manfred.reinart ,
here is my code and i haven't created abap type yet, will do it after getting the conversion in my dummy structre.
CALL METHOD cl_http_client=>create_by_urlca_data = dummy_struc.
2023 Jan 15 10:13 AM
you should sort out such issues by creating a self contained test program which takes the JSON string as constant input and then trying the remaining decoding.
This is then easier to reproduce than to rely on the HTTP communication upfront.
Have you also thought about checking on CALL TRANSFORMATION 'ID'?
2023 Jan 15 1:07 PM
In JSON, square brackets mean tables, but you defined structures in ABAP instead of table types...
NB: I agree with Manfred that you'd better create "a self contained test program which takes the JSON string as constant input and then trying the remaining decoding." It's also the way I troubleshoot issues and this way it's more easy to ask people to look at my issue if I can't find a solution myself.
2023 Jan 15 4:04 PM
Hi , while converting to ABAP structure, need to be careful while defining the exact matching structure with that of Json structure. Check that.
2023 Jan 16 10:22 AM
Thanku all for information. I am able to solve it by declaring the structure in the correct way and using /ui2/cl_json=>deserialize Method.