First, you should create the ABAP to JSON Writer with the CL_SXML_STRING_WRITER with Json as Type.
Then Call the transformation to convert the String to JSON formatted String .
The last Step is to retrieve the Output of the Writer in JSON.
DATA text TYPE string VALUE `Hello JSON, I’m ABAP!`.
DATA writer TYPE REF TO cl_sxml_string_writer.
DATA json TYPE xstring.
“ABAP to JSON
writer = cl_sxml_string_writer=>create( type = if_sxml=>co_xt_json ).
CALL TRANSFORMATION id SOURCE text = text
RESULT XML writer.
json = writer->get_output( ).
Output
for more information please read Serializer and Deserializer
UPDATE
Another example:
First, you should create the
ABAP
to JSON Writer with theCL_SXML_STRING_WRITER
withJson as Type.
Then Call the transformation to convert the String to JSON formatted String . The last Step is to retrieve the Output of the Writer in JSON.