Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
horst_keller
Product and Topic Expert
Product and Topic Expert
17,868
Displaying XML data is rather simple. HTML browsers understand XML too.
DATA itab TYPE TABLE OF i WITH EMPTY KEY.

itab = VALUE #( ( 1 ) ( 2 ) ( 3 ) ).

CALL TRANSFORMATION id SOURCE itab = itab
RESULT XML DATA(xml).

cl_abap_browser=>show_xml( xml_xstring = xml ).

Gives:


But what about JSON?
DATA itab TYPE TABLE OF i WITH EMPTY KEY.

itab = VALUE #( ( 1 ) ( 2 ) ( 3 ) ).

DATA(json_writer) = cl_sxml_string_writer=>create(
type = if_sxml=>co_xt_json ).
CALL TRANSFORMATION id SOURCE itab = itab
RESULT XML json_writer.
DATA(json) = json_writer->get_output( ).

cl_abap_browser=>show_xml( xml_xstring = json ).

Doesn't work ...
cl_abap_browser=>show_html( html_string = 
cl_abap_codepage=>convert_from( json ) ).

Works, but JSON is displayed simply as an unformatted text string.

To get a formatted output, for test cases you can use CL_DEMO_OUTPUT.
cl_demo_output=>display_json( json ).

Gives:

The big but: CL_DEMO_OUTPUT is not intended for productive usage.

Now look what I've "found": JSON, Transformation to HTML

You can use the XSL transformation SJSON2HTML in order to transform JSON to formatted HTML and use this with a browser.
CALL TRANSFORMATION sjson2html SOURCE XML json
RESULT XML DATA(html).

cl_abap_browser=>show_html( html_string =
cl_abap_codepage=>convert_from( html ) ).

Gives:

Even interactive. Maybe not perfect but at least something.

SJSON2HTML is available in release 7.02 already.

 

 

 
6 Comments
Labels in this area