2015 Aug 03 1:36 PM
Hello,
We are working on a project that sends json formatted payload to a target system via a rest webservice. We would like to follow camel case standard for labels in the json payload. I did a sample program to generate a Json payload and it works fine. But i see that labels are framed from components of the structure. I need to know if its possible to replace the labels with a camel casing format...like messageType in place of MESSAGETYPE or UniqueID in place of UNIQUEID etc..
Regards
Pradeep
2015 Aug 04 11:54 AM
Hi,
Try using a simple transformation, than I think you can specify your JSON labels manually and in camel case. Take a look here: https://scn.sap.com/community/abap/blog/2013/04/15/abap-2-json-and-json-2-abap-with-st
Best Regards,
Guilherme.
Hello,
We are working on a project that sends json formatted payload to a target system via a rest webservice. We would like to follow camel case standard for labels in the json payload. I did a sample program to generate a Json payload and it works fine. But i see that labels are framed from components of the structure. I need to know if its possible to replace the labels with a camel casing format...like messageType in place of MESSAGETYPE or UniqueID in place of UNIQUEID etc..
Regards
Pradeep
2015 Aug 03 4:29 PM
Hello!
Could you specity how do you generate JSON?
The field labels you get are in uppercase, are they?
2015 Aug 03 4:57 PM
Hello,
I have created a flat structure that has nested fields and table in SAP and filled this structure with data. Json payload is created using native SAP native json transformations. Yes, labels are in upper case. See below.
{
"DATA":
{
"HEADER":
{
"UNIQUEID":"XXXXXX",
.............................
..................
What i need is below:
{
"DATA":
{
"header":
{
"uniqueId":"XXXXXX",
.....................................
Thanks
Pradeep
2015 Aug 03 5:04 PM
2015 Aug 03 5:18 PM
Thanks for the link...but then i think it keeps everything in lower case. Somewhere i need to indicate the label i want to use. I understand that i have to create a simple transformation for this as per below help link ABAP Keyword Documentation
and demo program DEMO_ST_JSON_TABLE. Need to see how i can implement this..
Pradeep
2015 Aug 03 5:19 PM
2015 Aug 04 9:52 AM
It's very interesting challenge...
I suppose it is impossible to do it using a transformation of a dictionary structure or local structure, because you cannot declare structure field names using "camelCase". If you do it in ABAP editor the system will translate the field names to upper case anyway.
I think the only way is to create json manually.
2015 Aug 04 11:54 AM
Hi,
Try using a simple transformation, than I think you can specify your JSON labels manually and in camel case. Take a look here: https://scn.sap.com/community/abap/blog/2013/04/15/abap-2-json-and-json-2-abap-with-st
Best Regards,
Guilherme.
2015 Aug 05 11:09 AM
Hi,
This is working. I need a suggestion. I have a structure with fields including structures and tables. How do i prepare a ST for such a structure. I know that for tables i can use <tt:loop ref=".MYDATA">...and MYDATA is a table coming from CALL TRANSFORMATION and declared as a root name in ST.This works when i send a table. But i need to send a structure and how can i loop thru after passing structure, how can i add name of structure before showing data of structure. How can i do this. I searched for standard examples, but cant find for a nested structure.
Regards
Pradeep
2015 Aug 05 2:47 PM
I started some tests, thinking it would be a piece of cake... all I have now is exceptions and exceptions.
I'll keep you updated if I have positive results.
2015 Aug 05 3:15 PM
Finally! This took me some time to put together, but it was much easier after I looked at this post:
You should aim your transformation to generate this JSON-XML format.
Check my example:
Report: ZGD_TEST (attached)
Transformation (zgd_deep😞
<?sap.transform simple?>
<tt:transform xmlns:tt="http://www.sap.com/transformation-templates">
<tt:root name="ROOT"/>
<tt:template>
<object>
<str name="ValueA"><tt:value ref="ROOT.VALUE_A"/></str>
<object name="DeepStructure" tt:ref="ROOT.DEEP_STRUCTURE">
<str name="ValueB"><tt:value ref="VALUE_B"/></str>
<array name="SomeTable">
<tt:loop ref="SOME_TABLE">
<object>
<str name="ValueC"><tt:value ref="VALUE_C"/></str>
<str name="ValueD"><tt:value ref="VALUE_D"/></str>
</object>
</tt:loop>
</array>
</object>
</object>
</tt:template>
</tt:transform>
Best Regards,
Guilherme.
2015 Aug 05 2:32 PM
For the moment, i have achieved desired result by using XML writer class IF_SXML_WRITER. Need to try with a simple transformation..
| User | Count |
|---|---|
| 3 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |