Skip to Content
-3

JSON-to-ABAP Deserialize

Nov 20, 2017 at 11:26 AM

329

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Sandra Rossi Nov 20, 2017 at 01:09 PM
0

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.

Share
10 |10000 characters needed characters left characters exceeded
Horst Keller
Nov 20, 2017 at 01:31 PM
0

"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.

Show 2 Share
10 |10000 characters needed characters left characters exceeded

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

0
Konstantinos Vassiliadis

"I do have understanding"

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

0