"! <p class="shorttext synchronized" lang="en">Convert JSON to XML</p>
CLASS ZCL_JSON_TO_XML DEFINITION
  PUBLIC
  FINAL
  CREATE PUBLIC .

  PUBLIC SECTION.
    INTERFACES IF_OO_ADT_CLASSRUN.
  PROTECTED SECTION.
  PRIVATE SECTION.
ENDCLASS.



CLASS ZCL_JSON_TO_XML IMPLEMENTATION.


  METHOD IF_OO_ADT_CLASSRUN~MAIN.
*   DATA(json) = cl_abap_codepage=>convert_to( `{"TEXT":"JSON"}` ).
    DATA(JSON) = CL_ABAP_CONV_CODEPAGE=>CREATE_OUT(  )->CONVERT( `{"TEXT":"JSON"}` ).
    DATA(JSON_READER) = CL_SXML_STRING_READER=>CREATE( JSON ).
    DATA(XML_WRITER) = CL_SXML_STRING_WRITER=>CREATE( ).
    JSON_READER->NEXT_NODE( ).
    JSON_READER->SKIP_NODE( XML_WRITER ).

    TRY.
        DATA(READER) = CL_SXML_STRING_READER=>CREATE( XML_WRITER->GET_OUTPUT( ) ).
        DATA(WRITER) = CAST IF_SXML_WRITER(
                              CL_SXML_STRING_WRITER=>CREATE( ) ).
        WRITER->SET_OPTION( OPTION = IF_SXML_WRITER=>CO_OPT_LINEBREAKS ).
        WRITER->SET_OPTION( OPTION = IF_SXML_WRITER=>CO_OPT_INDENT ).
        READER->NEXT_NODE( ).
        READER->SKIP_NODE( WRITER ).
*       DATA(XML_OUTPUT) = CL_ABAP_CODEPAGE=>CONVERT_FROM( CAST CL_SXML_STRING_WRITER( WRITER )->GET_OUTPUT( ) ).
        DATA(XML_OUTPUT) = CL_ABAP_CONV_CODEPAGE=>CREATE_IN(  )->CONVERT( CAST CL_SXML_STRING_WRITER( WRITER )->GET_OUTPUT( ) ).
      CATCH CX_SXML_PARSE_ERROR.
        RETURN.
    ENDTRY.

    OUT->WRITE( XML_OUTPUT ).
  ENDMETHOD.
ENDCLASS.
