Convert JSON to ABAP Internal Table

 TYPES:
        BEGIN OF t_entry,
          access_token TYPE string,
          token_type   TYPE string,
          expires_in   TYPE n LENGTH 8,
          scope        TYPE string,
          jti          TYPE string,
        END OF t_entry .
      TYPES:
        t_entry_map TYPE SORTED TABLE OF t_entry WITH UNIQUE KEY access_token.
      DATA: m_entries TYPE t_entry.

      DATA: lr_instance  TYPE REF TO  /ui5/cl_json_parser.
      CREATE OBJECT lr_instance.
      CALL METHOD me->get_token.
      IF gv_token IS NOT INITIAL.

*        data: itab TYPE TABLE OF string.
*        data: access_tok type string.
*        SPLIT gv_token at '"' INTO TABLE itab.
*        try.
*            lv_auth2 = itab[ 4 ].
*          catch cx_sy_itab_line_not_found.
*        ENDTRY.

        /ui2/cl_json=>deserialize(
        EXPORTING json = gv_token pretty_name = /ui2/cl_json=>pretty_mode-camel_case CHANGING data = m_entries ).
        lv_auth2 = m_entries-access_token.
        gv_token = gv_token+17.

 

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.