Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 1

Suppose I have the following JSON data.

"data": "abc",

"tab": ["a", "b", "c"]

}<br>

I want to convert this to ABAP structure of the following structure.

|data |tab |

|"abc"|3 lines (first: "a", second: "b, third: "c") |

or,

|data |tab |

|"abc"|"a","b","c" |

At first I thought of defining a type and using /ui2/cl_json=>deserialize as below.

types: begin of ts_json,

data type string,

tab type string, "this is not right!

end of ts_json.

data(json) = '{ "data": "abc", "tab": ["a", "b", "c"] }'.

data ls_data type ts_json.

/ui2/cl_json=>deserialize(

exporting json = conv #( json )

changing data = ls_data

).

However, I'm stuck because the field "tab" is a table of string which does not have field names.

If I debug the code, ls_data-data is filled but ls_data-tab is blank.

How can I define such type that can receive an array of string as a table?

You might also like