[ABAP] XML nach JSON parsen

* XML-Daten
DATA(lv_xml) = |<object><str name="text">abcd</str><bool name="flag">true</bool><member name="number"><num>111</num></member><member name="content"><null /></member></object>|.

TRY.
* XML-Daten lesen
    DATA(o_r) = cl_sxml_string_reader=>create( input = cl_abap_codepage=>convert_to( lv_xml ) ).
* evtl. Objektkomponenten mit <member->-Elementen darstellen
*    reader->set_option( if_sxml_reader=>co_opt_sep_member ).

    DATA(o_w) = CAST if_sxml_writer( cl_sxml_string_writer=>create( type     = if_sxml=>co_xt_json
                                                                    encoding = 'UTF-8' ) ).
* Ausgabeoptionen setzen
    o_w->set_option( option = if_sxml_writer=>co_opt_linebreaks ).
    o_w->set_option( option = if_sxml_writer=>co_opt_indent ).

    o_r->next_node( ).
* JSON parsen
    o_r->skip_node( o_w ).

* Ausgabe konvertieren
    DATA(lv_json) = cl_abap_codepage=>convert_from( CAST cl_sxml_string_writer( o_w )->get_output( ) ).

* JSON ausgeben
    cl_demo_output=>display_json( lv_json ).
  CATCH cx_root INTO DATA(e_txt).
    WRITE: / e_txt->get_text( ).
ENDTRY.