cancel
Showing results for 
Search instead for 
Did you mean: 

JSON to ABAP

aabhas_wilmar
Contributor
0 Kudos

Hi all,

I have the following JSON response being returned from a third-party API.

I would like programmatically move it ABAP data structure to make use of it.

Couple of things:

1. It contains arrays without a name (valid JSON)

2. You would also see in lines like below, the key (or object name) is not available in all cases, just the value as part of the array.

"VALUES":[
               105333744
            ]

I understand that I need to define a deep structure to use CALL TRANSFORMATION id.

id Transformation would work if all values have their own name (please correct me if I am wrong) and a corresponding place to move into in the ABAP data structure.

Questions:

  • What do we do when there are unnamed objects / arrays in JSON data?
  • Is there a better way to deserialize complex JSON structures containing values without object names, arrays etc?
  • Is it possible to get this data returned into field-symbols or generic data so that developer doesn't need to worry about defining the structure (system determines the structure dynamically?

I have read many forum discussions and understand the basics of transforming plain JSON structure contain key-value pairs or arrays containing flat table structure to ABAP structure or internal tables.

My problem is similar to this unanswered forum question.

Thanks.

JSON response:

[
   {
      "AVAILABILITY":{
         "APPLICATIONCLOSES":{
            "CLOSEDATE":"2017-12-31T10:55:00.000Z"
         },
         "AVAILABLEEXT":true,
         "AVAILABLEINT":true,
         "JOBPUBLISHED":{
            "PUBLISHDAT":"2017-03-27T05:11:41.000Z"
         }
      },
      "CATEGORIES":[
         {
            "CATEGORY":104769015,
            "VALUES":[
               105333744
            ]
         },
         {
            "CATEGORY":100039352,
            "VALUES":[
               100109072
            ]
         },
         {
            "CATEGORY":100037613,
            "VALUES":[
               100042903
            ]
         },
         {
            "CATEGORY":100001999,
            "VALUES":[
               100039226
            ]
         },
         {
            "CATEGORY":100015632,
            "VALUES":[
               100015639
            ]
         },
         {
            "CATEGORY":100117002,
            "VALUES":[
               100117006
            ]
         },
         {
            "CATEGORY":100015595,
            "VALUES":[
               100015610
            ]
         },
         {
            "CATEGORY":100116504,
            "VALUES":[
               100116555
            ]
         }
      ],
      "CODE":"19399",
      "ID":105511844,
      "ITEMS":[
      ],
      "SHORTSUM":"<p>short description for app developer position</p><p>second line of description</p>",
      "TITLE":"App Developer"
   }
]

Accepted Solutions (1)

Accepted Solutions (1)

aabhas_wilmar
Contributor
0 Kudos

Resolved by writing a custom parser.

Answers (1)

Answers (1)

aabhas_wilmar
Contributor
0 Kudos

Any help would be highly appreciated.

I am currently investigating using CL_TREX_JSON_SERIALIZER and ABAP RTTI conepts.

Ideally, I would prefer not to modify the JSON response (and introduce object names to unnamed objects).

Unnamed objects:

"VALUES":[105333744,
105399999,
]

Objects with name:

"VALUES":["value":105333744,
"value":105399999,
]