Skip to Content
0

Convert ABAP data to JSON with camelCase Names.

Jan 31 at 03:14 PM

174

avatar image
Former Member

Hi all,

I'm looking to find the simplest method to take ABAP table data in SAP and format it into a json payload that apparently only accepts a variantion of camel case names. Examples being load, referenceNumbers, addressLine, etc.

Before I was aware of this restriction I created an abap structure with nested table types and used 'call transformation id' with a cl_sxml_string_writer created for json. This works fine other than all the structure fields are stored in uppercase so the json comes out that way. I could potentially do a find and replace on every field, but this seems like a poor solution. I've also read posts to the effect of using simple transformations, but I'm not very familiar with those and am having difficultly understanding how this would be helpful/implemented.

If anyone is willing to nudge me in right direction I would greatly appreciate it.

-Chris

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

2 Answers

Best Answer
Tomas Buryanek Jan 31 at 03:25 PM
3

/UI2/CL_JSON is pretty handy class to create JSON string from ABAP data.

It supports camelCase (pretty_name = /ui2/cl_json=>pretty_mode-camel_case).

Example:

In ABAP: test_name TYPE string.
In JSON: "testName"

or

In ABAP: test__name TYPE string.
In JSON: "test_name"
Share
10 |10000 characters needed characters left characters exceeded
Horst Keller
Jan 31 at 04:05 PM
2
Share
10 |10000 characters needed characters left characters exceeded