Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

JSON to ABAP Conversion

Former Member
0 Likes
6,634

Hi Experts

I am trying to Upload JSON file into SAP internal table and perform some actions on it.

I have referred already to these links:

https://blogs.sap.com/2013/01/07/abap-and-json/

https://answers.sap.com/questions/195916/complex-json-structure-to-abap.html and

https://archive.sap.com/discussions/thread/3817827

However, there is no information on how to UPLOAD a json file directly into an internal table.

Any pointers will be appreciated.


Regards

Dinesh

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,893

Hi..

Thanks for helping.. Solved the issue on own by reading character by character. In actual the json file was pretty complex and Standard SAP was taking a lot of time to deserialize.

Thanks

Hi Experts

I am trying to Upload JSON file into SAP internal table and perform some actions on it.

I have referred already to these links:

https://blogs.sap.com/2013/01/07/abap-and-json/

https://answers.sap.com/questions/195916/complex-json-structure-to-abap.html and

https://archive.sap.com/discussions/thread/3817827

However, there is no information on how to UPLOAD a json file directly into an internal table.

Any pointers will be appreciated.


Regards

Dinesh

3 REPLIES 3
Read only

1,892

Hi dear.

Follow this example, if it's what I imagined.

First, you have to create a structure like your json response;



TYPES:

TY_T_NAMES TYPE TABLE OF STRING WITH EMPTY KEY,

BEGIN OF TY_ROOT,
MESSAGE TYPE STRING,
NAMES   TYPE TY_T_NAMES,
END OF TY_ROOT.

DATA RESULT TYPE TY_ROOT.

  DATA(_JSON) = '{' &&
                   '"Message":"Hello",' &&
                   '"Names":["John","Julie","Mark","Juan"]' &&
                '}'.

After that, you can use this method to deserialize the data;

/UI2/CL_JSON=>DESERIALIZE( 
 EXPORTING 
   JSON = _JSON 
 CHANGING 
   DATA = RESULT ).

Check it

Enio,

Regards;

Read only

Former Member
0 Likes
1,894

Hi..

Thanks for helping.. Solved the issue on own by reading character by character. In actual the json file was pretty complex and Standard SAP was taking a lot of time to deserialize.

Thanks

Read only

0 Likes
1,892

For complexity, I can understand, but for performance a test of custom ABAP versus kernel had shown that ABAP is slower than kernel (performance ratio was 1.7 for ABAP versus 1 for Kernel - https://wiki.scn.sap.com/wiki/display/Snippets/Performance+of+JSON+from+scratch+-+sXML+versus+ZCL_MD... )