Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Data Interfaces and Communication Interfaces →  ABAP and JSON →  JSON, Examples 

JSON, Transformation to HTML

Transformation from JSON data to HTML.

Other versions: 7.31 | 7.40 | 7.54

Source Code

    SELECT *
           FROM scarr
           INTO TABLE @DATA(result)
           UP TO 3 ROWS.
    DATA(json_writer) = cl_sxml_string_writer=>create(
                          type = if_sxml=>co_xt_json ).
    CALL TRANSFORMATION id SOURCE result = result
                           RESULT XML json_writer.
    DATA(json) = json_writer->get_output( ).

    CALL TRANSFORMATION sjson2html SOURCE XML json
                                  RESULT XML DATA(html).

    cl_demo_output=>display_html(
      cl_abap_conv_codepage=>create_in( )->convert( html ) ).

Description

This example demonstrates how JSON data is transformed to SJSON2HTML to HTML using the transformation XSL. The nodes for objects and arrays can be opened and closed in the displayed result.