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: 

Convert ABAP data to JSON with camelCase Names.

former_member221827
Active Participant
0 Kudos

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

1 ACCEPTED SOLUTION

Tomas_Buryanek
Active Contributor

/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"
-- Tomas --
3 REPLIES 3

Tomas_Buryanek
Active Contributor

/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"
-- Tomas --

shalinee_gupta
Explorer
0 Kudos

Hi All,

I am trying to convert JSON into Internal table, do some operation on table and then covert the table back to JSON. I want to keep the fields of structure(which is used for JSON as it is. After serialization, the JSON should have field name same what I have given during deserialization.