Application Development 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: 

JSON-to-ABAP Deserialize

konstantinos_vassiliadis
Active Participant
0 Kudos

Dear experts,

I want to deserialize JSON data to ABAP structures. The ERP system is SAP_BASIS 700 and the following class methods are not available:

  • /ui2/cl_json=>deserialize
  • cl_trex_json_deserializer

So I am using the class cl_hrpayfr_json_deserializer which has a method DESERIALIZE that has input a variable of type string and returns a parameter of type ANY.

I want to deserialize the data to a structure and I understand that the return parameter of type ANY is a field symbol (?)

When I execute the code I get a runtime error of an unassigned field symbol although prior to calling the deserialize method I assign the target structure to the return parameter of type ANY.

Has anyone used the above method or used another method of deserializing?

Kind regards,

Konstantinos

4 REPLIES 4

Sandra_Rossi
Active Contributor
0 Kudos

No, of course you can't use a field symbol that you didn't assign first (ABAP basics).

Probably this parameter should be a complex structure data object corresponding to the input JSON (structure field names should probably be equal to the names in the JSON).

Maybe, instead of using this unreleased class cl_hrpayfr_json_deserializer (might be deleted in a future release, I don't have it in my ECC 6.0 EHP 7), you could use an open project, for instance https://github.com/cesar-sap/abap_fm_json . Of course, probably you will have to downport the code to ABAP 7.0.

horst_keller
Product and Topic Expert
Product and Topic Expert
0 Kudos

"I want to deserialize the data to a structure and I understand that the return parameter of type ANY is a field symbol (?)"

I fear, you have to understand typing of parameters and the concept of field symbols first.

0 Kudos

I do have understanding but I do not understand how else to deserialize input JSON.

horst_keller
Product and Topic Expert
Product and Topic Expert
0 Kudos

"I do have understanding"

Then please debug to check where and why the exception occurs.