mirror of
https://github.com/abap2UI5/abap2UI5.git
synced 2025-04-29 15:16:15 +08:00
update ajson mirror (#1379)
This commit is contained in:
parent
8d9efe5409
commit
860f03d05e
43
.github/workflows/ajson_mirror.yaml
vendored
Normal file
43
.github/workflows/ajson_mirror.yaml
vendored
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
name: ajson mirror
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 0 * * 1'
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
pr_ajson_changes:
|
||||||
|
# Origin repo only
|
||||||
|
permissions:
|
||||||
|
contents: write # for peter-evans/create-pull-request to create branch
|
||||||
|
pull-requests: write # for peter-evans/create-pull-request to create a PR
|
||||||
|
if: github.repository == 'abap2UI5/abap2UI5'
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
- uses: actions/setup-node@v4
|
||||||
|
- name: run
|
||||||
|
run: |
|
||||||
|
git clone https://github.com/abap2UI5/ajson_mirror.git
|
||||||
|
ls -l
|
||||||
|
rm src/01/00/01/z*
|
||||||
|
cp ajson_mirror/src/z* src/01/00/01/
|
||||||
|
rm -rf ajson_mirror
|
||||||
|
git status
|
||||||
|
- name: Open PR
|
||||||
|
uses: peter-evans/create-pull-request@v3
|
||||||
|
with:
|
||||||
|
title: ajson, Automatic Update
|
||||||
|
branch: automatic/ajson
|
||||||
|
body: |
|
||||||
|
Automatic update from mirror
|
||||||
|
https://github.com/abap2UI5/ajson_mirror
|
||||||
|
|
||||||
|
Make manual change to trigger CI
|
||||||
|
|
||||||
|
Note: manual changes might be overwritten when the branch updates, so keep changes small, and merge fast
|
File diff suppressed because it is too large
Load Diff
|
@ -59,25 +59,25 @@ CLASS lcl_utils DEFINITION FINAL.
|
||||||
|
|
||||||
CLASS-METHODS normalize_path
|
CLASS-METHODS normalize_path
|
||||||
IMPORTING
|
IMPORTING
|
||||||
iv_path TYPE string
|
iv_path TYPE string
|
||||||
RETURNING
|
RETURNING
|
||||||
VALUE(rv_path) TYPE string.
|
VALUE(rv_path) TYPE string.
|
||||||
CLASS-METHODS split_path
|
CLASS-METHODS split_path
|
||||||
IMPORTING
|
IMPORTING
|
||||||
iv_path TYPE string
|
iv_path TYPE string
|
||||||
RETURNING
|
RETURNING
|
||||||
VALUE(rv_path_name) TYPE z2ui5_if_ajson_types=>ty_path_name.
|
VALUE(rv_path_name) TYPE z2ui5_if_ajson_types=>ty_path_name.
|
||||||
CLASS-METHODS validate_array_index
|
CLASS-METHODS validate_array_index
|
||||||
IMPORTING
|
IMPORTING
|
||||||
iv_path TYPE string
|
iv_path TYPE string
|
||||||
iv_index TYPE string
|
iv_index TYPE string
|
||||||
RETURNING
|
RETURNING
|
||||||
VALUE(rv_index) TYPE i
|
VALUE(rv_index) TYPE i
|
||||||
RAISING
|
RAISING
|
||||||
z2UI5_cx_ajson_error.
|
z2ui5_cx_ajson_error.
|
||||||
CLASS-METHODS string_to_xstring_utf8
|
CLASS-METHODS string_to_xstring_utf8
|
||||||
IMPORTING
|
IMPORTING
|
||||||
iv_str TYPE string
|
iv_str TYPE string
|
||||||
RETURNING
|
RETURNING
|
||||||
VALUE(rv_xstr) TYPE xstring.
|
VALUE(rv_xstr) TYPE xstring.
|
||||||
|
|
||||||
|
@ -94,24 +94,24 @@ CLASS lcl_utils IMPLEMENTATION.
|
||||||
|
|
||||||
TRY.
|
TRY.
|
||||||
CALL METHOD ('CL_ABAP_CONV_CODEPAGE')=>create_out
|
CALL METHOD ('CL_ABAP_CONV_CODEPAGE')=>create_out
|
||||||
RECEIVING
|
RECEIVING
|
||||||
instance = lo_conv.
|
instance = lo_conv.
|
||||||
CALL METHOD lo_conv->('IF_ABAP_CONV_OUT~CONVERT')
|
CALL METHOD lo_conv->('IF_ABAP_CONV_OUT~CONVERT')
|
||||||
EXPORTING
|
EXPORTING
|
||||||
source = iv_str
|
source = iv_str
|
||||||
RECEIVING
|
RECEIVING
|
||||||
result = rv_xstr.
|
result = rv_xstr.
|
||||||
CATCH cx_sy_dyn_call_illegal_class.
|
CATCH cx_sy_dyn_call_illegal_class.
|
||||||
CALL METHOD (lv_out_ce)=>create
|
CALL METHOD (lv_out_ce)=>create
|
||||||
EXPORTING
|
EXPORTING
|
||||||
encoding = 'UTF-8'
|
encoding = 'UTF-8'
|
||||||
RECEIVING
|
RECEIVING
|
||||||
conv = lo_conv.
|
conv = lo_conv.
|
||||||
CALL METHOD lo_conv->('CONVERT')
|
CALL METHOD lo_conv->('CONVERT')
|
||||||
EXPORTING
|
EXPORTING
|
||||||
data = iv_str
|
data = iv_str
|
||||||
IMPORTING
|
IMPORTING
|
||||||
buffer = rv_xstr.
|
buffer = rv_xstr.
|
||||||
ENDTRY.
|
ENDTRY.
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
@ -137,7 +137,8 @@ CLASS lcl_utils IMPLEMENTATION.
|
||||||
IF rv_path+0(1) <> '/'.
|
IF rv_path+0(1) <> '/'.
|
||||||
rv_path = '/' && rv_path.
|
rv_path = '/' && rv_path.
|
||||||
ENDIF.
|
ENDIF.
|
||||||
IF substring( val = rv_path off = strlen( rv_path ) - 1 ) <> '/'.
|
IF substring( val = rv_path
|
||||||
|
off = strlen( rv_path ) - 1 ) <> '/'.
|
||||||
rv_path = rv_path && '/'.
|
rv_path = rv_path && '/'.
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
|
@ -154,18 +155,24 @@ CLASS lcl_utils IMPLEMENTATION.
|
||||||
RETURN. " empty path is the alias for root item = '' + ''
|
RETURN. " empty path is the alias for root item = '' + ''
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
IF substring( val = iv_path off = lv_len - 1 ) = '/'.
|
IF substring( val = iv_path
|
||||||
|
off = lv_len - 1 ) = '/'.
|
||||||
lv_trim_slash = 1. " ignore last '/'
|
lv_trim_slash = 1. " ignore last '/'
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
lv_offs = find( val = reverse( iv_path ) sub = '/' off = lv_trim_slash ).
|
lv_offs = find( val = reverse( iv_path )
|
||||||
|
sub = '/'
|
||||||
|
off = lv_trim_slash ).
|
||||||
IF lv_offs = -1.
|
IF lv_offs = -1.
|
||||||
lv_offs = lv_len. " treat whole string as the 'name' part
|
lv_offs = lv_len. " treat whole string as the 'name' part
|
||||||
ENDIF.
|
ENDIF.
|
||||||
lv_offs = lv_len - lv_offs.
|
lv_offs = lv_len - lv_offs.
|
||||||
|
|
||||||
rv_path_name-path = normalize_path( substring( val = iv_path len = lv_offs ) ).
|
rv_path_name-path = normalize_path( substring( val = iv_path
|
||||||
rv_path_name-name = substring( val = iv_path off = lv_offs len = lv_len - lv_offs - lv_trim_slash ).
|
len = lv_offs ) ).
|
||||||
|
rv_path_name-name = substring( val = iv_path
|
||||||
|
off = lv_offs
|
||||||
|
len = lv_len - lv_offs - lv_trim_slash ).
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
@ -181,8 +188,8 @@ CLASS lcl_json_parser DEFINITION FINAL.
|
||||||
|
|
||||||
METHODS parse
|
METHODS parse
|
||||||
IMPORTING
|
IMPORTING
|
||||||
iv_json TYPE string
|
iv_json TYPE string
|
||||||
iv_keep_item_order TYPE abap_bool DEFAULT abap_false
|
iv_keep_item_order TYPE abap_bool DEFAULT abap_false
|
||||||
RETURNING
|
RETURNING
|
||||||
VALUE(rt_json_tree) TYPE z2ui5_if_ajson_types=>ty_nodes_tt
|
VALUE(rt_json_tree) TYPE z2ui5_if_ajson_types=>ty_nodes_tt
|
||||||
RAISING
|
RAISING
|
||||||
|
@ -205,7 +212,7 @@ CLASS lcl_json_parser DEFINITION FINAL.
|
||||||
|
|
||||||
METHODS _parse
|
METHODS _parse
|
||||||
IMPORTING
|
IMPORTING
|
||||||
iv_json TYPE string
|
iv_json TYPE string
|
||||||
RETURNING
|
RETURNING
|
||||||
VALUE(rt_json_tree) TYPE z2ui5_if_ajson_types=>ty_nodes_tt
|
VALUE(rt_json_tree) TYPE z2ui5_if_ajson_types=>ty_nodes_tt
|
||||||
RAISING
|
RAISING
|
||||||
|
@ -230,21 +237,21 @@ CLASS lcl_json_parser IMPLEMENTATION.
|
||||||
mv_keep_item_order = iv_keep_item_order.
|
mv_keep_item_order = iv_keep_item_order.
|
||||||
|
|
||||||
TRY.
|
TRY.
|
||||||
" TODO sane JSON check:
|
" TODO sane JSON check:
|
||||||
" JSON can be true,false,null,(-)digits
|
" JSON can be true,false,null,(-)digits
|
||||||
" or start from " or from {
|
" or start from " or from {
|
||||||
rt_json_tree = _parse( iv_json ).
|
rt_json_tree = _parse( iv_json ).
|
||||||
CATCH cx_sxml_parse_error INTO lx_sxml_parse.
|
CATCH cx_sxml_parse_error INTO lx_sxml_parse.
|
||||||
lv_location = _get_location(
|
lv_location = _get_location(
|
||||||
iv_json = iv_json
|
iv_json = iv_json
|
||||||
iv_offset = lx_sxml_parse->xml_offset ).
|
iv_offset = lx_sxml_parse->xml_offset ).
|
||||||
z2ui5_cx_ajson_error=>raise(
|
z2ui5_cx_ajson_error=>raise(
|
||||||
iv_msg = |Json parsing error (SXML): { lx_sxml_parse->get_text( ) }|
|
iv_msg = |Json parsing error (SXML): { lx_sxml_parse->get_text( ) }|
|
||||||
iv_location = lv_location ).
|
iv_location = lv_location ).
|
||||||
CATCH cx_dynamic_check INTO lx_sxml. " cx_sxml_error
|
CATCH cx_dynamic_check INTO lx_sxml. " cx_sxml_error
|
||||||
z2ui5_cx_ajson_error=>raise(
|
z2ui5_cx_ajson_error=>raise(
|
||||||
iv_msg = |Json parsing error (SXML): { lx_sxml->get_text( ) }|
|
iv_msg = |Json parsing error (SXML): { lx_sxml->get_text( ) }|
|
||||||
iv_location = '@PARSER' ).
|
iv_location = '@PARSER' ).
|
||||||
ENDTRY.
|
ENDTRY.
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
@ -253,7 +260,7 @@ CLASS lcl_json_parser IMPLEMENTATION.
|
||||||
|
|
||||||
DATA lv_json TYPE string.
|
DATA lv_json TYPE string.
|
||||||
DATA lv_offset TYPE i.
|
DATA lv_offset TYPE i.
|
||||||
DATA lt_text TYPE STANDARD TABLE OF string.
|
DATA lt_text TYPE TABLE OF string.
|
||||||
DATA lv_text TYPE string.
|
DATA lv_text TYPE string.
|
||||||
DATA lv_line TYPE i.
|
DATA lv_line TYPE i.
|
||||||
DATA lv_pos TYPE i.
|
DATA lv_pos TYPE i.
|
||||||
|
@ -361,7 +368,8 @@ CLASS lcl_json_parser IMPLEMENTATION.
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
" remove last path component
|
" remove last path component
|
||||||
mv_stack_path = substring( val = mv_stack_path len = find( val = mv_stack_path sub = '/' occ = -2 ) + 1 ).
|
mv_stack_path = substring( val = mv_stack_path
|
||||||
|
len = find( val = mv_stack_path sub = '/' occ = -2 ) + 1 ).
|
||||||
WHEN if_sxml_node=>co_nt_value.
|
WHEN if_sxml_node=>co_nt_value.
|
||||||
DATA lo_value TYPE REF TO if_sxml_value_node.
|
DATA lo_value TYPE REF TO if_sxml_value_node.
|
||||||
lo_value ?= lo_node.
|
lo_value ?= lo_node.
|
||||||
|
@ -398,9 +406,9 @@ CLASS lcl_json_serializer DEFINITION FINAL CREATE PRIVATE.
|
||||||
|
|
||||||
CLASS-METHODS stringify
|
CLASS-METHODS stringify
|
||||||
IMPORTING
|
IMPORTING
|
||||||
it_json_tree TYPE z2ui5_if_ajson_types=>ty_nodes_ts
|
it_json_tree TYPE z2ui5_if_ajson_types=>ty_nodes_ts
|
||||||
iv_indent TYPE i DEFAULT 0
|
iv_indent TYPE i DEFAULT 0
|
||||||
iv_keep_item_order TYPE abap_bool DEFAULT abap_false
|
iv_keep_item_order TYPE abap_bool DEFAULT abap_false
|
||||||
RETURNING
|
RETURNING
|
||||||
VALUE(rv_json_string) TYPE string
|
VALUE(rv_json_string) TYPE string
|
||||||
RAISING
|
RAISING
|
||||||
|
@ -420,7 +428,7 @@ CLASS lcl_json_serializer DEFINITION FINAL CREATE PRIVATE.
|
||||||
|
|
||||||
CLASS-METHODS escape_string
|
CLASS-METHODS escape_string
|
||||||
IMPORTING
|
IMPORTING
|
||||||
iv_unescaped TYPE string
|
iv_unescaped TYPE string
|
||||||
RETURNING
|
RETURNING
|
||||||
VALUE(rv_escaped) TYPE string.
|
VALUE(rv_escaped) TYPE string.
|
||||||
|
|
||||||
|
@ -439,7 +447,7 @@ CLASS lcl_json_serializer DEFINITION FINAL CREATE PRIVATE.
|
||||||
METHODS stringify_set
|
METHODS stringify_set
|
||||||
IMPORTING
|
IMPORTING
|
||||||
iv_parent_path TYPE string
|
iv_parent_path TYPE string
|
||||||
iv_array TYPE abap_bool
|
iv_array TYPE abap_bool
|
||||||
RAISING
|
RAISING
|
||||||
z2ui5_cx_ajson_error.
|
z2ui5_cx_ajson_error.
|
||||||
|
|
||||||
|
@ -485,7 +493,8 @@ CLASS lcl_json_serializer IMPLEMENTATION.
|
||||||
DATA lv_indent_prefix TYPE string.
|
DATA lv_indent_prefix TYPE string.
|
||||||
|
|
||||||
IF mv_indent_step > 0.
|
IF mv_indent_step > 0.
|
||||||
lv_indent_prefix = repeat( val = ` ` occ = mv_indent_step * mv_level ).
|
lv_indent_prefix = repeat( val = ` `
|
||||||
|
occ = mv_indent_step * mv_level ).
|
||||||
lv_item = lv_indent_prefix.
|
lv_item = lv_indent_prefix.
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
|
@ -641,7 +650,7 @@ CLASS lcl_json_to_abap DEFINITION FINAL.
|
||||||
|
|
||||||
METHODS to_abap
|
METHODS to_abap
|
||||||
IMPORTING
|
IMPORTING
|
||||||
it_nodes TYPE z2ui5_if_ajson_types=>ty_nodes_ts
|
it_nodes TYPE z2ui5_if_ajson_types=>ty_nodes_ts
|
||||||
CHANGING
|
CHANGING
|
||||||
c_container TYPE any
|
c_container TYPE any
|
||||||
RAISING
|
RAISING
|
||||||
|
@ -689,16 +698,16 @@ CLASS lcl_json_to_abap DEFINITION FINAL.
|
||||||
|
|
||||||
METHODS any_to_abap
|
METHODS any_to_abap
|
||||||
IMPORTING
|
IMPORTING
|
||||||
iv_path TYPE string
|
iv_path TYPE string
|
||||||
is_parent_type TYPE ty_type_cache OPTIONAL
|
is_parent_type TYPE ty_type_cache OPTIONAL
|
||||||
i_container_ref TYPE REF TO data
|
i_container_ref TYPE REF TO data
|
||||||
RAISING
|
RAISING
|
||||||
z2ui5_cx_ajson_error.
|
z2ui5_cx_ajson_error.
|
||||||
|
|
||||||
METHODS value_to_abap
|
METHODS value_to_abap
|
||||||
IMPORTING
|
IMPORTING
|
||||||
is_node TYPE z2ui5_if_ajson_types=>ty_node
|
is_node TYPE z2ui5_if_ajson_types=>ty_node
|
||||||
is_node_type TYPE ty_type_cache
|
is_node_type TYPE ty_type_cache
|
||||||
i_container_ref TYPE REF TO data
|
i_container_ref TYPE REF TO data
|
||||||
RAISING
|
RAISING
|
||||||
z2ui5_cx_ajson_error
|
z2ui5_cx_ajson_error
|
||||||
|
@ -706,9 +715,9 @@ CLASS lcl_json_to_abap DEFINITION FINAL.
|
||||||
|
|
||||||
METHODS get_node_type
|
METHODS get_node_type
|
||||||
IMPORTING
|
IMPORTING
|
||||||
is_node TYPE z2ui5_if_ajson_types=>ty_node OPTIONAL " Empty for root
|
is_node TYPE z2ui5_if_ajson_types=>ty_node OPTIONAL " Empty for root
|
||||||
is_parent_type TYPE ty_type_cache OPTIONAL
|
is_parent_type TYPE ty_type_cache OPTIONAL
|
||||||
i_container_ref TYPE REF TO data OPTIONAL
|
i_container_ref TYPE REF TO data OPTIONAL
|
||||||
RETURNING
|
RETURNING
|
||||||
VALUE(rs_node_type) TYPE ty_type_cache
|
VALUE(rs_node_type) TYPE ty_type_cache
|
||||||
RAISING
|
RAISING
|
||||||
|
@ -852,16 +861,16 @@ CLASS lcl_json_to_abap IMPLEMENTATION.
|
||||||
|
|
||||||
TRY.
|
TRY.
|
||||||
|
|
||||||
" array_index because stringified index goes in wrong order [1, 10, 2 ...]
|
" array_index because stringified index goes in wrong order [1, 10, 2 ...]
|
||||||
LOOP AT mr_nodes->* ASSIGNING <n> USING KEY array_index WHERE path = iv_path.
|
LOOP AT mr_nodes->* ASSIGNING <n> USING KEY array_index WHERE path = iv_path.
|
||||||
|
|
||||||
" Get or create type cache record
|
" Get or create type cache record
|
||||||
IF is_parent_type-type_kind <> lif_kind=>table OR ls_node_type-type_kind IS INITIAL.
|
IF is_parent_type-type_kind <> lif_kind=>table OR ls_node_type-type_kind IS INITIAL.
|
||||||
" table records are the same, no need to refetch twice
|
" table records are the same, no need to refetch twice
|
||||||
|
|
||||||
ls_node_type = get_node_type(
|
ls_node_type = get_node_type(
|
||||||
is_node = <n>
|
is_node = <n>
|
||||||
is_parent_type = is_parent_type ).
|
is_parent_type = is_parent_type ).
|
||||||
|
|
||||||
IF mv_corresponding = abap_true AND ls_node_type IS INITIAL.
|
IF mv_corresponding = abap_true AND ls_node_type IS INITIAL.
|
||||||
CONTINUE.
|
CONTINUE.
|
||||||
|
@ -869,24 +878,26 @@ CLASS lcl_json_to_abap IMPLEMENTATION.
|
||||||
|
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
" Validate node type
|
" Validate node type
|
||||||
IF ls_node_type-type_kind = lif_kind=>data_ref OR
|
IF ls_node_type-type_kind = lif_kind=>data_ref OR
|
||||||
ls_node_type-type_kind = lif_kind=>object_ref.
|
ls_node_type-type_kind = lif_kind=>object_ref.
|
||||||
" TODO maybe in future
|
" TODO maybe in future
|
||||||
z2ui5_cx_ajson_error=>raise( 'Cannot assign to ref' ).
|
z2ui5_cx_ajson_error=>raise( 'Cannot assign to ref' ).
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
" Find target field reference
|
" Find target field reference
|
||||||
CASE is_parent_type-type_kind.
|
CASE is_parent_type-type_kind.
|
||||||
WHEN lif_kind=>table.
|
WHEN lif_kind=>table.
|
||||||
IF NOT ls_node_type-target_field_name CO '0123456789'.
|
IF NOT ls_node_type-target_field_name CO '0123456789'.
|
||||||
" Does not affect anything actually but for integrity
|
" Does not affect anything actually but for integrity
|
||||||
z2ui5_cx_ajson_error=>raise( 'Need index to access tables' ).
|
z2ui5_cx_ajson_error=>raise( 'Need index to access tables' ).
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
IF is_parent_type-tab_item_buf IS NOT BOUND. " Indirect hint that table was srt/hsh, see get_node_type
|
IF is_parent_type-tab_item_buf IS NOT BOUND. " Indirect hint that table was srt/hsh, see get_node_type
|
||||||
APPEND INITIAL LINE TO <parent_stdtab> REFERENCE INTO lr_target_field.
|
APPEND INITIAL LINE TO <parent_stdtab> REFERENCE INTO lr_target_field.
|
||||||
ASSERT sy-subrc = 0.
|
ASSERT sy-subrc = 0.
|
||||||
|
ELSE.
|
||||||
|
CLEAR <tab_item>.
|
||||||
ENDIF.
|
ENDIF.
|
||||||
|
|
||||||
WHEN lif_kind=>struct_flat OR lif_kind=>struct_deep.
|
WHEN lif_kind=>struct_flat OR lif_kind=>struct_deep.
|
||||||
|
@ -902,32 +913,32 @@ CLASS lcl_json_to_abap IMPLEMENTATION.
|
||||||
z2ui5_cx_ajson_error=>raise( 'Unexpected parent type' ).
|
z2ui5_cx_ajson_error=>raise( 'Unexpected parent type' ).
|
||||||
ENDCASE.
|
ENDCASE.
|
||||||
|
|
||||||
" Process value assignment
|
" Process value assignment
|
||||||
CASE <n>-type.
|
CASE <n>-type.
|
||||||
WHEN z2ui5_if_ajson_types=>node_type-object.
|
WHEN z2ui5_if_ajson_types=>node_type-object.
|
||||||
IF ls_node_type-type_kind <> lif_kind=>struct_flat AND
|
IF ls_node_type-type_kind <> lif_kind=>struct_flat AND
|
||||||
ls_node_type-type_kind <> lif_kind=>struct_deep.
|
ls_node_type-type_kind <> lif_kind=>struct_deep.
|
||||||
z2ui5_cx_ajson_error=>raise( 'Expected structure' ).
|
z2ui5_cx_ajson_error=>raise( 'Expected structure' ).
|
||||||
ENDIF.
|
ENDIF.
|
||||||
any_to_abap(
|
any_to_abap(
|
||||||
iv_path = <n>-path && <n>-name && '/'
|
iv_path = <n>-path && <n>-name && '/'
|
||||||
is_parent_type = ls_node_type
|
is_parent_type = ls_node_type
|
||||||
i_container_ref = lr_target_field ).
|
i_container_ref = lr_target_field ).
|
||||||
|
|
||||||
WHEN z2ui5_if_ajson_types=>node_type-array.
|
WHEN z2ui5_if_ajson_types=>node_type-array.
|
||||||
IF NOT ls_node_type-type_kind = lif_kind=>table.
|
IF NOT ls_node_type-type_kind = lif_kind=>table.
|
||||||
z2ui5_cx_ajson_error=>raise( 'Expected table' ).
|
z2ui5_cx_ajson_error=>raise( 'Expected table' ).
|
||||||
ENDIF.
|
ENDIF.
|
||||||
any_to_abap(
|
any_to_abap(
|
||||||
iv_path = <n>-path && <n>-name && '/'
|
iv_path = <n>-path && <n>-name && '/'
|
||||||
is_parent_type = ls_node_type
|
is_parent_type = ls_node_type
|
||||||
i_container_ref = lr_target_field ).
|
i_container_ref = lr_target_field ).
|
||||||
|
|
||||||
WHEN OTHERS.
|
WHEN OTHERS.
|
||||||
value_to_abap(
|
value_to_abap(
|
||||||
is_node = <n>
|
is_node = <n>
|
||||||
is_node_type = ls_node_type
|
is_node_type = ls_node_type
|
||||||
i_container_ref = lr_target_field ).
|
i_container_ref = lr_target_field ).
|
||||||
ENDCASE.
|
ENDCASE.
|
||||||
|
|
||||||
IF is_parent_type-tab_item_buf IS BOUND. " Indirect hint that table was sorted/hashed, see get_node_type.
|
IF is_parent_type-tab_item_buf IS BOUND. " Indirect hint that table was sorted/hashed, see get_node_type.
|
||||||
|
@ -950,12 +961,12 @@ CLASS lcl_json_to_abap IMPLEMENTATION.
|
||||||
RAISE EXCEPTION lx_ajson.
|
RAISE EXCEPTION lx_ajson.
|
||||||
CATCH cx_sy_conversion_no_number.
|
CATCH cx_sy_conversion_no_number.
|
||||||
z2ui5_cx_ajson_error=>raise(
|
z2ui5_cx_ajson_error=>raise(
|
||||||
iv_msg = 'Source is not a number'
|
iv_msg = 'Source is not a number'
|
||||||
iv_location = <n>-path && <n>-name ).
|
iv_location = <n>-path && <n>-name ).
|
||||||
CATCH cx_root INTO lx_root.
|
CATCH cx_root INTO lx_root.
|
||||||
z2ui5_cx_ajson_error=>raise(
|
z2ui5_cx_ajson_error=>raise(
|
||||||
iv_msg = lx_root->get_text( )
|
iv_msg = lx_root->get_text( )
|
||||||
iv_location = <n>-path && <n>-name ).
|
iv_location = <n>-path && <n>-name ).
|
||||||
ENDTRY.
|
ENDTRY.
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
@ -1011,7 +1022,7 @@ CLASS lcl_json_to_abap IMPLEMENTATION.
|
||||||
DATA lv_m TYPE c LENGTH 2.
|
DATA lv_m TYPE c LENGTH 2.
|
||||||
DATA lv_d TYPE c LENGTH 2.
|
DATA lv_d TYPE c LENGTH 2.
|
||||||
|
|
||||||
FIND FIRST OCCURRENCE OF REGEX '^(\d{4})-(\d{2})-(\d{2})(T|$)' "#EC NOTEXT
|
FIND FIRST OCCURRENCE OF REGEX '^(\d{4})-(\d{2})-(\d{2})(T|$)'
|
||||||
IN iv_value
|
IN iv_value
|
||||||
SUBMATCHES lv_y lv_m lv_d.
|
SUBMATCHES lv_y lv_m lv_d.
|
||||||
IF sy-subrc <> 0.
|
IF sy-subrc <> 0.
|
||||||
|
@ -1025,9 +1036,9 @@ CLASS lcl_json_to_abap IMPLEMENTATION.
|
||||||
|
|
||||||
CONSTANTS lc_utc TYPE c LENGTH 6 VALUE 'UTC'.
|
CONSTANTS lc_utc TYPE c LENGTH 6 VALUE 'UTC'.
|
||||||
CONSTANTS lc_regex_ts_with_hour TYPE string
|
CONSTANTS lc_regex_ts_with_hour TYPE string
|
||||||
VALUE `^(\d{4})-(\d{2})-(\d{2})(T)(\d{2}):(\d{2}):(\d{2})(\+)(\d{2}):(\d{2})`. "#EC NOTEXT
|
VALUE `^(\d{4})-(\d{2})-(\d{2})(T)(\d{2}):(\d{2}):(\d{2})(\+)(\d{2}):(\d{2})`.
|
||||||
CONSTANTS lc_regex_ts_utc TYPE string
|
CONSTANTS lc_regex_ts_utc TYPE string
|
||||||
VALUE `^(\d{4})-(\d{2})-(\d{2})(T)(\d{2}):(\d{2}):(\d{2})(Z|$)`. "#EC NOTEXT
|
VALUE `^(\d{4})-(\d{2})-(\d{2})(T)(\d{2}):(\d{2}):(\d{2})(Z|$)`.
|
||||||
|
|
||||||
DATA:
|
DATA:
|
||||||
BEGIN OF ls_timestamp,
|
BEGIN OF ls_timestamp,
|
||||||
|
@ -1081,12 +1092,12 @@ CLASS lcl_json_to_abap IMPLEMENTATION.
|
||||||
CASE ls_timestamp-local_sign.
|
CASE ls_timestamp-local_sign.
|
||||||
WHEN '-'.
|
WHEN '-'.
|
||||||
lv_timestamp = cl_abap_tstmp=>add(
|
lv_timestamp = cl_abap_tstmp=>add(
|
||||||
tstmp = lv_timestamp
|
tstmp = lv_timestamp
|
||||||
secs = lv_seconds_conv ).
|
secs = lv_seconds_conv ).
|
||||||
WHEN '+'.
|
WHEN '+'.
|
||||||
lv_timestamp = cl_abap_tstmp=>subtractsecs(
|
lv_timestamp = cl_abap_tstmp=>subtractsecs(
|
||||||
tstmp = lv_timestamp
|
tstmp = lv_timestamp
|
||||||
secs = lv_seconds_conv ).
|
secs = lv_seconds_conv ).
|
||||||
ENDCASE.
|
ENDCASE.
|
||||||
|
|
||||||
CATCH cx_parameter_invalid_range cx_parameter_invalid_type.
|
CATCH cx_parameter_invalid_range cx_parameter_invalid_type.
|
||||||
|
@ -1109,7 +1120,7 @@ CLASS lcl_json_to_abap IMPLEMENTATION.
|
||||||
DATA lv_m TYPE c LENGTH 2.
|
DATA lv_m TYPE c LENGTH 2.
|
||||||
DATA lv_s TYPE c LENGTH 2.
|
DATA lv_s TYPE c LENGTH 2.
|
||||||
|
|
||||||
FIND FIRST OCCURRENCE OF REGEX '^(\d{2}):(\d{2}):(\d{2})(T|$)' "#EC NOTEXT
|
FIND FIRST OCCURRENCE OF REGEX '^(\d{2}):(\d{2}):(\d{2})(T|$)'
|
||||||
IN iv_value
|
IN iv_value
|
||||||
SUBMATCHES lv_h lv_m lv_s.
|
SUBMATCHES lv_h lv_m lv_s.
|
||||||
IF sy-subrc <> 0.
|
IF sy-subrc <> 0.
|
||||||
|
@ -1130,12 +1141,12 @@ CLASS lcl_abap_to_json DEFINITION FINAL.
|
||||||
|
|
||||||
CLASS-METHODS convert
|
CLASS-METHODS convert
|
||||||
IMPORTING
|
IMPORTING
|
||||||
iv_data TYPE any
|
iv_data TYPE any
|
||||||
is_prefix TYPE z2ui5_if_ajson_types=>ty_path_name OPTIONAL
|
is_prefix TYPE z2ui5_if_ajson_types=>ty_path_name OPTIONAL
|
||||||
iv_array_index TYPE i DEFAULT 0
|
iv_array_index TYPE i DEFAULT 0
|
||||||
ii_custom_mapping TYPE REF TO z2ui5_if_ajson_mapping OPTIONAL
|
ii_custom_mapping TYPE REF TO z2ui5_if_ajson_mapping OPTIONAL
|
||||||
is_opts TYPE z2ui5_if_ajson=>ty_opts OPTIONAL
|
is_opts TYPE z2ui5_if_ajson=>ty_opts OPTIONAL
|
||||||
iv_item_order TYPE i DEFAULT 0
|
iv_item_order TYPE i DEFAULT 0
|
||||||
RETURNING
|
RETURNING
|
||||||
VALUE(rt_nodes) TYPE z2ui5_if_ajson_types=>ty_nodes_tt
|
VALUE(rt_nodes) TYPE z2ui5_if_ajson_types=>ty_nodes_tt
|
||||||
RAISING
|
RAISING
|
||||||
|
@ -1143,13 +1154,13 @@ CLASS lcl_abap_to_json DEFINITION FINAL.
|
||||||
|
|
||||||
CLASS-METHODS insert_with_type
|
CLASS-METHODS insert_with_type
|
||||||
IMPORTING
|
IMPORTING
|
||||||
iv_data TYPE any
|
iv_data TYPE any
|
||||||
iv_type TYPE z2ui5_if_ajson_types=>ty_node_type
|
iv_type TYPE z2ui5_if_ajson_types=>ty_node_type
|
||||||
is_prefix TYPE z2ui5_if_ajson_types=>ty_path_name OPTIONAL
|
is_prefix TYPE z2ui5_if_ajson_types=>ty_path_name OPTIONAL
|
||||||
iv_array_index TYPE i DEFAULT 0
|
iv_array_index TYPE i DEFAULT 0
|
||||||
ii_custom_mapping TYPE REF TO z2ui5_if_ajson_mapping OPTIONAL
|
ii_custom_mapping TYPE REF TO z2ui5_if_ajson_mapping OPTIONAL
|
||||||
is_opts TYPE z2ui5_if_ajson=>ty_opts OPTIONAL
|
is_opts TYPE z2ui5_if_ajson=>ty_opts OPTIONAL
|
||||||
iv_item_order TYPE i DEFAULT 0
|
iv_item_order TYPE i DEFAULT 0
|
||||||
RETURNING
|
RETURNING
|
||||||
VALUE(rt_nodes) TYPE z2ui5_if_ajson_types=>ty_nodes_tt
|
VALUE(rt_nodes) TYPE z2ui5_if_ajson_types=>ty_nodes_tt
|
||||||
RAISING
|
RAISING
|
||||||
|
@ -1157,17 +1168,17 @@ CLASS lcl_abap_to_json DEFINITION FINAL.
|
||||||
|
|
||||||
CLASS-METHODS format_date
|
CLASS-METHODS format_date
|
||||||
IMPORTING
|
IMPORTING
|
||||||
iv_date TYPE d
|
iv_date TYPE d
|
||||||
RETURNING
|
RETURNING
|
||||||
VALUE(rv_str) TYPE string.
|
VALUE(rv_str) TYPE string.
|
||||||
CLASS-METHODS format_time
|
CLASS-METHODS format_time
|
||||||
IMPORTING
|
IMPORTING
|
||||||
iv_time TYPE t
|
iv_time TYPE t
|
||||||
RETURNING
|
RETURNING
|
||||||
VALUE(rv_str) TYPE string.
|
VALUE(rv_str) TYPE string.
|
||||||
CLASS-METHODS format_timestamp
|
CLASS-METHODS format_timestamp
|
||||||
IMPORTING
|
IMPORTING
|
||||||
iv_ts TYPE timestamp
|
iv_ts TYPE timestamp
|
||||||
RETURNING
|
RETURNING
|
||||||
VALUE(rv_str) TYPE string.
|
VALUE(rv_str) TYPE string.
|
||||||
|
|
||||||
|
@ -1182,84 +1193,84 @@ CLASS lcl_abap_to_json DEFINITION FINAL.
|
||||||
|
|
||||||
METHODS convert_any
|
METHODS convert_any
|
||||||
IMPORTING
|
IMPORTING
|
||||||
iv_data TYPE any
|
iv_data TYPE any
|
||||||
io_type TYPE REF TO cl_abap_typedescr
|
io_type TYPE REF TO cl_abap_typedescr
|
||||||
is_prefix TYPE z2ui5_if_ajson_types=>ty_path_name
|
is_prefix TYPE z2ui5_if_ajson_types=>ty_path_name
|
||||||
iv_index TYPE i DEFAULT 0
|
iv_index TYPE i DEFAULT 0
|
||||||
iv_item_order TYPE i DEFAULT 0
|
iv_item_order TYPE i DEFAULT 0
|
||||||
CHANGING
|
CHANGING
|
||||||
ct_nodes TYPE z2ui5_if_ajson_types=>ty_nodes_tt
|
ct_nodes TYPE z2ui5_if_ajson_types=>ty_nodes_tt
|
||||||
RAISING
|
RAISING
|
||||||
z2ui5_cx_ajson_error.
|
z2ui5_cx_ajson_error.
|
||||||
|
|
||||||
METHODS convert_ajson
|
METHODS convert_ajson
|
||||||
IMPORTING
|
IMPORTING
|
||||||
io_json TYPE REF TO z2ui5_if_ajson
|
io_json TYPE REF TO z2ui5_if_ajson
|
||||||
is_prefix TYPE z2ui5_if_ajson_types=>ty_path_name
|
is_prefix TYPE z2ui5_if_ajson_types=>ty_path_name
|
||||||
iv_index TYPE i DEFAULT 0
|
iv_index TYPE i DEFAULT 0
|
||||||
iv_item_order TYPE i DEFAULT 0
|
iv_item_order TYPE i DEFAULT 0
|
||||||
CHANGING
|
CHANGING
|
||||||
ct_nodes TYPE z2ui5_if_ajson_types=>ty_nodes_tt
|
ct_nodes TYPE z2ui5_if_ajson_types=>ty_nodes_tt
|
||||||
RAISING
|
RAISING
|
||||||
z2ui5_cx_ajson_error.
|
z2ui5_cx_ajson_error.
|
||||||
|
|
||||||
METHODS convert_value
|
METHODS convert_value
|
||||||
IMPORTING
|
IMPORTING
|
||||||
iv_data TYPE any
|
iv_data TYPE any
|
||||||
io_type TYPE REF TO cl_abap_typedescr
|
io_type TYPE REF TO cl_abap_typedescr
|
||||||
is_prefix TYPE z2ui5_if_ajson_types=>ty_path_name
|
is_prefix TYPE z2ui5_if_ajson_types=>ty_path_name
|
||||||
iv_index TYPE i DEFAULT 0
|
iv_index TYPE i DEFAULT 0
|
||||||
iv_item_order TYPE i DEFAULT 0
|
iv_item_order TYPE i DEFAULT 0
|
||||||
CHANGING
|
CHANGING
|
||||||
ct_nodes TYPE z2ui5_if_ajson_types=>ty_nodes_tt
|
ct_nodes TYPE z2ui5_if_ajson_types=>ty_nodes_tt
|
||||||
RAISING
|
RAISING
|
||||||
z2ui5_cx_ajson_error.
|
z2ui5_cx_ajson_error.
|
||||||
|
|
||||||
METHODS convert_ref
|
METHODS convert_ref
|
||||||
IMPORTING
|
IMPORTING
|
||||||
iv_data TYPE any
|
iv_data TYPE any
|
||||||
is_prefix TYPE z2ui5_if_ajson_types=>ty_path_name
|
is_prefix TYPE z2ui5_if_ajson_types=>ty_path_name
|
||||||
iv_index TYPE i DEFAULT 0
|
iv_index TYPE i DEFAULT 0
|
||||||
iv_item_order TYPE i DEFAULT 0
|
iv_item_order TYPE i DEFAULT 0
|
||||||
CHANGING
|
CHANGING
|
||||||
ct_nodes TYPE z2ui5_if_ajson_types=>ty_nodes_tt
|
ct_nodes TYPE z2ui5_if_ajson_types=>ty_nodes_tt
|
||||||
RAISING
|
RAISING
|
||||||
z2ui5_cx_ajson_error.
|
z2ui5_cx_ajson_error.
|
||||||
|
|
||||||
METHODS convert_struc
|
METHODS convert_struc
|
||||||
IMPORTING
|
IMPORTING
|
||||||
iv_data TYPE any
|
iv_data TYPE any
|
||||||
io_type TYPE REF TO cl_abap_typedescr
|
io_type TYPE REF TO cl_abap_typedescr
|
||||||
is_prefix TYPE z2ui5_if_ajson_types=>ty_path_name
|
is_prefix TYPE z2ui5_if_ajson_types=>ty_path_name
|
||||||
iv_index TYPE i DEFAULT 0
|
iv_index TYPE i DEFAULT 0
|
||||||
iv_item_order TYPE i DEFAULT 0
|
iv_item_order TYPE i DEFAULT 0
|
||||||
CHANGING
|
CHANGING
|
||||||
ct_nodes TYPE z2ui5_if_ajson_types=>ty_nodes_tt
|
ct_nodes TYPE z2ui5_if_ajson_types=>ty_nodes_tt
|
||||||
RAISING
|
RAISING
|
||||||
z2ui5_cx_ajson_error.
|
z2ui5_cx_ajson_error.
|
||||||
|
|
||||||
METHODS convert_table
|
METHODS convert_table
|
||||||
IMPORTING
|
IMPORTING
|
||||||
iv_data TYPE any
|
iv_data TYPE any
|
||||||
io_type TYPE REF TO cl_abap_typedescr
|
io_type TYPE REF TO cl_abap_typedescr
|
||||||
is_prefix TYPE z2ui5_if_ajson_types=>ty_path_name
|
is_prefix TYPE z2ui5_if_ajson_types=>ty_path_name
|
||||||
iv_index TYPE i DEFAULT 0
|
iv_index TYPE i DEFAULT 0
|
||||||
iv_item_order TYPE i DEFAULT 0
|
iv_item_order TYPE i DEFAULT 0
|
||||||
CHANGING
|
CHANGING
|
||||||
ct_nodes TYPE z2ui5_if_ajson_types=>ty_nodes_tt
|
ct_nodes TYPE z2ui5_if_ajson_types=>ty_nodes_tt
|
||||||
RAISING
|
RAISING
|
||||||
z2ui5_cx_ajson_error.
|
z2ui5_cx_ajson_error.
|
||||||
|
|
||||||
METHODS insert_value_with_type
|
METHODS insert_value_with_type
|
||||||
IMPORTING
|
IMPORTING
|
||||||
iv_data TYPE any
|
iv_data TYPE any
|
||||||
iv_type TYPE z2ui5_if_ajson_types=>ty_node_type
|
iv_type TYPE z2ui5_if_ajson_types=>ty_node_type
|
||||||
io_type TYPE REF TO cl_abap_typedescr
|
io_type TYPE REF TO cl_abap_typedescr
|
||||||
is_prefix TYPE z2ui5_if_ajson_types=>ty_path_name
|
is_prefix TYPE z2ui5_if_ajson_types=>ty_path_name
|
||||||
iv_index TYPE i DEFAULT 0
|
iv_index TYPE i DEFAULT 0
|
||||||
iv_item_order TYPE i DEFAULT 0
|
iv_item_order TYPE i DEFAULT 0
|
||||||
CHANGING
|
CHANGING
|
||||||
ct_nodes TYPE z2ui5_if_ajson_types=>ty_nodes_tt
|
ct_nodes TYPE z2ui5_if_ajson_types=>ty_nodes_tt
|
||||||
RAISING
|
RAISING
|
||||||
z2ui5_cx_ajson_error.
|
z2ui5_cx_ajson_error.
|
||||||
|
|
||||||
|
@ -1740,7 +1751,7 @@ INTERFACE lif_mutator_runner.
|
||||||
IMPORTING
|
IMPORTING
|
||||||
it_source_tree TYPE z2ui5_if_ajson_types=>ty_nodes_ts
|
it_source_tree TYPE z2ui5_if_ajson_types=>ty_nodes_ts
|
||||||
EXPORTING
|
EXPORTING
|
||||||
et_dest_tree TYPE z2ui5_if_ajson_types=>ty_nodes_ts
|
et_dest_tree TYPE z2ui5_if_ajson_types=>ty_nodes_ts
|
||||||
RAISING
|
RAISING
|
||||||
z2ui5_cx_ajson_error.
|
z2ui5_cx_ajson_error.
|
||||||
ENDINTERFACE.
|
ENDINTERFACE.
|
||||||
|
@ -1754,7 +1765,7 @@ CLASS lcl_filter_runner DEFINITION FINAL.
|
||||||
INTERFACES lif_mutator_runner.
|
INTERFACES lif_mutator_runner.
|
||||||
CLASS-METHODS new
|
CLASS-METHODS new
|
||||||
IMPORTING
|
IMPORTING
|
||||||
ii_filter TYPE REF TO z2ui5_if_ajson_filter
|
ii_filter TYPE REF TO z2ui5_if_ajson_filter
|
||||||
RETURNING
|
RETURNING
|
||||||
VALUE(ro_instance) TYPE REF TO lcl_filter_runner.
|
VALUE(ro_instance) TYPE REF TO lcl_filter_runner.
|
||||||
METHODS constructor
|
METHODS constructor
|
||||||
|
@ -1768,7 +1779,7 @@ CLASS lcl_filter_runner DEFINITION FINAL.
|
||||||
|
|
||||||
METHODS walk
|
METHODS walk
|
||||||
IMPORTING
|
IMPORTING
|
||||||
iv_path TYPE string
|
iv_path TYPE string
|
||||||
CHANGING
|
CHANGING
|
||||||
cs_parent TYPE z2ui5_if_ajson_types=>ty_node OPTIONAL
|
cs_parent TYPE z2ui5_if_ajson_types=>ty_node OPTIONAL
|
||||||
RAISING
|
RAISING
|
||||||
|
@ -1866,7 +1877,7 @@ CLASS lcl_mapper_runner DEFINITION FINAL.
|
||||||
INTERFACES lif_mutator_runner.
|
INTERFACES lif_mutator_runner.
|
||||||
CLASS-METHODS new
|
CLASS-METHODS new
|
||||||
IMPORTING
|
IMPORTING
|
||||||
ii_mapper TYPE REF TO z2ui5_if_ajson_mapping
|
ii_mapper TYPE REF TO z2ui5_if_ajson_mapping
|
||||||
RETURNING
|
RETURNING
|
||||||
VALUE(ro_instance) TYPE REF TO lcl_mapper_runner.
|
VALUE(ro_instance) TYPE REF TO lcl_mapper_runner.
|
||||||
METHODS constructor
|
METHODS constructor
|
||||||
|
@ -1980,7 +1991,7 @@ CLASS lcl_mutator_queue DEFINITION FINAL.
|
||||||
VALUE(ro_instance) TYPE REF TO lcl_mutator_queue.
|
VALUE(ro_instance) TYPE REF TO lcl_mutator_queue.
|
||||||
METHODS add
|
METHODS add
|
||||||
IMPORTING
|
IMPORTING
|
||||||
ii_mutator TYPE REF TO lif_mutator_runner
|
ii_mutator TYPE REF TO lif_mutator_runner
|
||||||
RETURNING
|
RETURNING
|
||||||
VALUE(ro_self) TYPE REF TO lcl_mutator_queue.
|
VALUE(ro_self) TYPE REF TO lcl_mutator_queue.
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ CLASS ltcl_parser_test DEFINITION FINAL
|
||||||
|
|
||||||
CLASS-METHODS sample_json
|
CLASS-METHODS sample_json
|
||||||
IMPORTING
|
IMPORTING
|
||||||
iv_separator TYPE string OPTIONAL
|
iv_separator TYPE string OPTIONAL
|
||||||
RETURNING
|
RETURNING
|
||||||
VALUE(rv_json) TYPE string.
|
VALUE(rv_json) TYPE string.
|
||||||
|
|
||||||
|
@ -146,26 +146,26 @@ CLASS ltcl_parser_test IMPLEMENTATION.
|
||||||
cl_abap_unit_assert=>fail( 'Parsing of string w/o quotes must fail (spec)' ).
|
cl_abap_unit_assert=>fail( 'Parsing of string w/o quotes must fail (spec)' ).
|
||||||
CATCH z2ui5_cx_ajson_error INTO lx_err.
|
CATCH z2ui5_cx_ajson_error INTO lx_err.
|
||||||
cl_abap_unit_assert=>assert_char_cp(
|
cl_abap_unit_assert=>assert_char_cp(
|
||||||
act = lx_err->get_text( )
|
act = lx_err->get_text( )
|
||||||
exp = '*parsing error*' ).
|
exp = '*parsing error*' ).
|
||||||
cl_abap_unit_assert=>assert_char_cp(
|
cl_abap_unit_assert=>assert_char_cp(
|
||||||
act = lx_err->location
|
act = lx_err->location
|
||||||
exp = 'Line 1, Offset 1' ).
|
exp = 'Line 1, Offset 1' ).
|
||||||
ENDTRY.
|
ENDTRY.
|
||||||
|
|
||||||
TRY.
|
TRY.
|
||||||
lt_act = mo_cut->parse( '{' && cl_abap_char_utilities=>newline
|
lt_act = mo_cut->parse( '{' && cl_abap_char_utilities=>newline
|
||||||
&& '"ok": "abc",' && cl_abap_char_utilities=>newline
|
&& '"ok": "abc",' && cl_abap_char_utilities=>newline
|
||||||
&& '"error"' && cl_abap_char_utilities=>newline
|
&& '"error"' && cl_abap_char_utilities=>newline
|
||||||
&& '}' ).
|
&& '}' ).
|
||||||
cl_abap_unit_assert=>fail( 'Parsing of invalid JSON must fail (spec)' ).
|
cl_abap_unit_assert=>fail( 'Parsing of invalid JSON must fail (spec)' ).
|
||||||
CATCH z2ui5_cx_ajson_error INTO lx_err.
|
CATCH z2ui5_cx_ajson_error INTO lx_err.
|
||||||
cl_abap_unit_assert=>assert_char_cp(
|
cl_abap_unit_assert=>assert_char_cp(
|
||||||
act = lx_err->get_text( )
|
act = lx_err->get_text( )
|
||||||
exp = '*parsing error*' ).
|
exp = '*parsing error*' ).
|
||||||
cl_abap_unit_assert=>assert_char_cp(
|
cl_abap_unit_assert=>assert_char_cp(
|
||||||
act = lx_err->location
|
act = lx_err->location
|
||||||
exp = 'Line 3, Offset 8' ).
|
exp = 'Line 3, Offset 8' ).
|
||||||
ENDTRY.
|
ENDTRY.
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
@ -822,13 +822,15 @@ CLASS ltcl_utils_test IMPLEMENTATION.
|
||||||
exp = 123 ).
|
exp = 123 ).
|
||||||
|
|
||||||
TRY.
|
TRY.
|
||||||
lcl_utils=>validate_array_index( iv_path = 'x' iv_index = 'a' ).
|
lcl_utils=>validate_array_index( iv_path = 'x'
|
||||||
|
iv_index = 'a' ).
|
||||||
cl_abap_unit_assert=>fail( ).
|
cl_abap_unit_assert=>fail( ).
|
||||||
CATCH z2ui5_cx_ajson_error.
|
CATCH z2ui5_cx_ajson_error.
|
||||||
ENDTRY.
|
ENDTRY.
|
||||||
|
|
||||||
TRY.
|
TRY.
|
||||||
lcl_utils=>validate_array_index( iv_path = 'x' iv_index = '0' ).
|
lcl_utils=>validate_array_index( iv_path = 'x'
|
||||||
|
iv_index = '0' ).
|
||||||
cl_abap_unit_assert=>fail( ).
|
cl_abap_unit_assert=>fail( ).
|
||||||
CATCH z2ui5_cx_ajson_error.
|
CATCH z2ui5_cx_ajson_error.
|
||||||
ENDTRY.
|
ENDTRY.
|
||||||
|
@ -1331,8 +1333,8 @@ CLASS ltcl_reader_test IMPLEMENTATION.
|
||||||
cl_abap_unit_assert=>fail( ).
|
cl_abap_unit_assert=>fail( ).
|
||||||
CATCH z2ui5_cx_ajson_error INTO lx.
|
CATCH z2ui5_cx_ajson_error INTO lx.
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = lx->message
|
act = lx->message
|
||||||
exp = 'Path not found: /x' ).
|
exp = 'Path not found: /x' ).
|
||||||
ENDTRY.
|
ENDTRY.
|
||||||
|
|
||||||
TRY.
|
TRY.
|
||||||
|
@ -1340,8 +1342,8 @@ CLASS ltcl_reader_test IMPLEMENTATION.
|
||||||
cl_abap_unit_assert=>fail( ).
|
cl_abap_unit_assert=>fail( ).
|
||||||
CATCH z2ui5_cx_ajson_error INTO lx.
|
CATCH z2ui5_cx_ajson_error INTO lx.
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = lx->message
|
act = lx->message
|
||||||
exp = 'Array expected at: /' ).
|
exp = 'Array expected at: /' ).
|
||||||
ENDTRY.
|
ENDTRY.
|
||||||
|
|
||||||
TRY.
|
TRY.
|
||||||
|
@ -1349,8 +1351,8 @@ CLASS ltcl_reader_test IMPLEMENTATION.
|
||||||
cl_abap_unit_assert=>fail( ).
|
cl_abap_unit_assert=>fail( ).
|
||||||
CATCH z2ui5_cx_ajson_error INTO lx.
|
CATCH z2ui5_cx_ajson_error INTO lx.
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = lx->message
|
act = lx->message
|
||||||
exp = 'Array expected at: /a' ).
|
exp = 'Array expected at: /a' ).
|
||||||
ENDTRY.
|
ENDTRY.
|
||||||
|
|
||||||
CREATE OBJECT lo_nodes.
|
CREATE OBJECT lo_nodes.
|
||||||
|
@ -1363,8 +1365,8 @@ CLASS ltcl_reader_test IMPLEMENTATION.
|
||||||
cl_abap_unit_assert=>fail( ).
|
cl_abap_unit_assert=>fail( ).
|
||||||
CATCH z2ui5_cx_ajson_error INTO lx.
|
CATCH z2ui5_cx_ajson_error INTO lx.
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = lx->message
|
act = lx->message
|
||||||
exp = 'Cannot convert [object] to string at [/1]' ).
|
exp = 'Cannot convert [object] to string at [/1]' ).
|
||||||
ENDTRY.
|
ENDTRY.
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
@ -1389,75 +1391,96 @@ CLASS ltcl_json_to_abap DEFINITION
|
||||||
a TYPE string,
|
a TYPE string,
|
||||||
b TYPE i,
|
b TYPE i,
|
||||||
END OF ty_struc,
|
END OF ty_struc,
|
||||||
tty_struc TYPE STANDARD TABLE OF ty_struc WITH KEY a,
|
tty_struc TYPE STANDARD TABLE OF ty_struc WITH KEY a,
|
||||||
tty_struc_sorted TYPE SORTED TABLE OF ty_struc WITH UNIQUE KEY a,
|
tty_struc_sorted TYPE SORTED TABLE OF ty_struc WITH UNIQUE KEY a,
|
||||||
tty_struc_hashed TYPE HASHED TABLE OF ty_struc WITH UNIQUE KEY a,
|
tty_struc_hashed TYPE HASHED TABLE OF ty_struc WITH UNIQUE KEY a,
|
||||||
BEGIN OF ty_complex,
|
BEGIN OF ty_complex,
|
||||||
str TYPE string,
|
str TYPE string,
|
||||||
int TYPE i,
|
int TYPE i,
|
||||||
float TYPE f,
|
float TYPE f,
|
||||||
bool TYPE abap_bool,
|
bool TYPE abap_bool,
|
||||||
obj TYPE ty_struc,
|
obj TYPE ty_struc,
|
||||||
tab TYPE tty_struc,
|
tab TYPE tty_struc,
|
||||||
tab_plain TYPE string_table,
|
tab_plain TYPE string_table,
|
||||||
tab_hashed TYPE tty_struc_hashed,
|
tab_hashed TYPE tty_struc_hashed,
|
||||||
oref TYPE REF TO object,
|
oref TYPE REF TO object,
|
||||||
date1 TYPE d,
|
date1 TYPE d,
|
||||||
date2 TYPE d,
|
date2 TYPE d,
|
||||||
timestamp1 TYPE timestamp,
|
timestamp1 TYPE timestamp,
|
||||||
timestamp2 TYPE timestamp,
|
timestamp2 TYPE timestamp,
|
||||||
timestamp3 TYPE timestamp,
|
timestamp3 TYPE timestamp,
|
||||||
|
timestamp4 TYPE timestampl,
|
||||||
END OF ty_complex.
|
END OF ty_complex.
|
||||||
|
|
||||||
METHODS to_abap_struc
|
METHODS to_abap_struc
|
||||||
FOR TESTING
|
FOR TESTING
|
||||||
RAISING z2ui5_cx_ajson_error.
|
RAISING z2ui5_cx_ajson_error.
|
||||||
METHODS to_abap_timestamp_initial
|
METHODS to_abap_timestamp_initial
|
||||||
FOR TESTING
|
FOR TESTING
|
||||||
RAISING z2ui5_cx_ajson_error.
|
RAISING z2ui5_cx_ajson_error.
|
||||||
METHODS to_abap_value
|
METHODS to_abap_value
|
||||||
FOR TESTING
|
FOR TESTING
|
||||||
RAISING z2ui5_cx_ajson_error.
|
RAISING z2ui5_cx_ajson_error.
|
||||||
METHODS to_abap_array
|
METHODS to_abap_array
|
||||||
FOR TESTING
|
FOR TESTING
|
||||||
RAISING z2ui5_cx_ajson_error.
|
RAISING z2ui5_cx_ajson_error.
|
||||||
METHODS to_abap_array_of_arrays_simple
|
METHODS to_abap_array_of_arrays_simple
|
||||||
FOR TESTING
|
FOR TESTING
|
||||||
RAISING z2ui5_cx_ajson_error.
|
RAISING z2ui5_cx_ajson_error.
|
||||||
METHODS to_abap_array_of_arrays
|
METHODS to_abap_array_of_arrays
|
||||||
FOR TESTING
|
FOR TESTING
|
||||||
RAISING z2ui5_cx_ajson_error.
|
RAISING z2ui5_cx_ajson_error.
|
||||||
METHODS to_abap_w_tab_of_struc
|
METHODS to_abap_w_tab_of_struc
|
||||||
FOR TESTING
|
FOR TESTING
|
||||||
RAISING z2ui5_cx_ajson_error.
|
RAISING z2ui5_cx_ajson_error.
|
||||||
METHODS to_abap_w_plain_tab
|
METHODS to_abap_w_plain_tab
|
||||||
FOR TESTING
|
FOR TESTING
|
||||||
RAISING z2ui5_cx_ajson_error.
|
RAISING z2ui5_cx_ajson_error.
|
||||||
METHODS to_abap_hashed_tab
|
METHODS to_abap_hashed_tab
|
||||||
FOR TESTING
|
FOR TESTING
|
||||||
RAISING z2ui5_cx_ajson_error.
|
RAISING z2ui5_cx_ajson_error.
|
||||||
METHODS to_abap_sorted_tab
|
METHODS to_abap_sorted_tab
|
||||||
FOR TESTING
|
FOR TESTING
|
||||||
RAISING z2ui5_cx_ajson_error.
|
RAISING z2ui5_cx_ajson_error.
|
||||||
METHODS to_abap_hashed_plain_tab
|
METHODS to_abap_hashed_plain_tab
|
||||||
FOR TESTING
|
FOR TESTING
|
||||||
|
RAISING z2ui5_cx_ajson_error.
|
||||||
|
METHODS to_abap_negative
|
||||||
|
FOR TESTING
|
||||||
RAISING z2ui5_cx_ajson_error.
|
RAISING z2ui5_cx_ajson_error.
|
||||||
METHODS to_abap_corresponding
|
METHODS to_abap_corresponding
|
||||||
FOR TESTING
|
FOR TESTING
|
||||||
RAISING z2ui5_cx_ajson_error.
|
RAISING z2ui5_cx_ajson_error.
|
||||||
METHODS to_abap_corresponding_negative
|
METHODS to_abap_corresponding_negative
|
||||||
FOR TESTING
|
FOR TESTING
|
||||||
RAISING z2ui5_cx_ajson_error.
|
RAISING z2ui5_cx_ajson_error.
|
||||||
METHODS to_abap_corresponding_public
|
METHODS to_abap_corresponding_public
|
||||||
FOR TESTING
|
FOR TESTING
|
||||||
RAISING z2ui5_cx_ajson_error.
|
RAISING z2ui5_cx_ajson_error.
|
||||||
METHODS to_abap_corresponding_pub_neg
|
METHODS to_abap_corresponding_pub_neg
|
||||||
FOR TESTING
|
FOR TESTING
|
||||||
RAISING z2ui5_cx_ajson_error.
|
RAISING z2ui5_cx_ajson_error.
|
||||||
METHODS to_abap_time
|
METHODS to_abap_time
|
||||||
FOR TESTING
|
FOR TESTING
|
||||||
|
RAISING cx_static_check.
|
||||||
|
METHODS to_abap_str_to_packed
|
||||||
|
FOR TESTING
|
||||||
|
RAISING cx_static_check.
|
||||||
|
METHODS to_abap_compressed_stdrd
|
||||||
|
FOR TESTING
|
||||||
|
RAISING cx_static_check.
|
||||||
|
METHODS to_abap_compressed_stdrd_key
|
||||||
|
FOR TESTING
|
||||||
|
RAISING cx_static_check.
|
||||||
|
METHODS to_abap_compressed_sort
|
||||||
|
FOR TESTING
|
||||||
|
RAISING cx_static_check.
|
||||||
|
METHODS to_abap_compressed_sort_unique
|
||||||
|
FOR TESTING
|
||||||
|
RAISING cx_static_check.
|
||||||
|
METHODS to_abap_compressed_hash
|
||||||
|
FOR TESTING
|
||||||
RAISING cx_static_check.
|
RAISING cx_static_check.
|
||||||
|
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
||||||
CLASS z2ui5_cl_ajson DEFINITION LOCAL FRIENDS ltcl_json_to_abap.
|
CLASS z2ui5_cl_ajson DEFINITION LOCAL FRIENDS ltcl_json_to_abap.
|
||||||
|
@ -1487,6 +1510,7 @@ CLASS ltcl_json_to_abap IMPLEMENTATION.
|
||||||
lo_nodes->add( '/ |timestamp1 |str |2020-07-28T00:00:00 | ' ).
|
lo_nodes->add( '/ |timestamp1 |str |2020-07-28T00:00:00 | ' ).
|
||||||
lo_nodes->add( '/ |timestamp2 |str |2020-07-28T00:00:00Z | ' ).
|
lo_nodes->add( '/ |timestamp2 |str |2020-07-28T00:00:00Z | ' ).
|
||||||
lo_nodes->add( '/ |timestamp3 |str |2020-07-28T01:00:00+01:00 | ' ).
|
lo_nodes->add( '/ |timestamp3 |str |2020-07-28T01:00:00+01:00 | ' ).
|
||||||
|
lo_nodes->add( '/ |timestamp4 |str |2020-07-28T01:00:00+01:00 | ' ).
|
||||||
|
|
||||||
CREATE OBJECT lo_cut.
|
CREATE OBJECT lo_cut.
|
||||||
lo_cut->to_abap(
|
lo_cut->to_abap(
|
||||||
|
@ -1505,6 +1529,7 @@ CLASS ltcl_json_to_abap IMPLEMENTATION.
|
||||||
ls_exp-timestamp1 = lv_exp_timestamp.
|
ls_exp-timestamp1 = lv_exp_timestamp.
|
||||||
ls_exp-timestamp2 = lv_exp_timestamp.
|
ls_exp-timestamp2 = lv_exp_timestamp.
|
||||||
ls_exp-timestamp3 = lv_exp_timestamp.
|
ls_exp-timestamp3 = lv_exp_timestamp.
|
||||||
|
ls_exp-timestamp4 = lv_exp_timestamp.
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = ls_mock
|
act = ls_mock
|
||||||
|
@ -1554,21 +1579,43 @@ CLASS ltcl_json_to_abap IMPLEMENTATION.
|
||||||
act = lv_mock
|
act = lv_mock
|
||||||
exp = '111111' ).
|
exp = '111111' ).
|
||||||
|
|
||||||
* DATA lv_mock_init TYPE t.
|
DATA lv_mock_init TYPE t.
|
||||||
*
|
|
||||||
* CREATE OBJECT lo_nodes.
|
CREATE OBJECT lo_nodes.
|
||||||
* lo_nodes->add( ' | |str || ' ).
|
lo_nodes->add( ' | |str || ' ).
|
||||||
*
|
|
||||||
* CREATE OBJECT lo_cut.
|
CREATE OBJECT lo_cut.
|
||||||
* lo_cut->to_abap(
|
lo_cut->to_abap(
|
||||||
* EXPORTING
|
EXPORTING
|
||||||
* it_nodes = lo_nodes->sorted( )
|
it_nodes = lo_nodes->sorted( )
|
||||||
* CHANGING
|
CHANGING
|
||||||
* c_container = lv_mock_init ).
|
c_container = lv_mock_init ).
|
||||||
*
|
|
||||||
* cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
* act = lv_mock_init
|
act = lv_mock_init
|
||||||
* exp = '000000' ).
|
exp = '000000' ).
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD to_abap_str_to_packed.
|
||||||
|
|
||||||
|
DATA lo_cut TYPE REF TO lcl_json_to_abap.
|
||||||
|
DATA lv_act TYPE p LENGTH 10 DECIMALS 3.
|
||||||
|
DATA lo_nodes TYPE REF TO lcl_nodes_helper.
|
||||||
|
|
||||||
|
CREATE OBJECT lo_nodes.
|
||||||
|
lo_nodes->add( ' | |str |1.3333 | ' ).
|
||||||
|
|
||||||
|
CREATE OBJECT lo_cut.
|
||||||
|
lo_cut->to_abap(
|
||||||
|
EXPORTING
|
||||||
|
it_nodes = lo_nodes->sorted( )
|
||||||
|
CHANGING
|
||||||
|
c_container = lv_act ).
|
||||||
|
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = lv_act
|
||||||
|
exp = '1.333' ).
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
@ -1625,8 +1672,8 @@ CLASS ltcl_json_to_abap IMPLEMENTATION.
|
||||||
METHOD to_abap_array_of_arrays_simple.
|
METHOD to_abap_array_of_arrays_simple.
|
||||||
|
|
||||||
DATA lo_cut TYPE REF TO lcl_json_to_abap.
|
DATA lo_cut TYPE REF TO lcl_json_to_abap.
|
||||||
DATA lt_mock TYPE STANDARD TABLE OF string_table.
|
DATA lt_mock TYPE TABLE OF string_table.
|
||||||
DATA lt_exp TYPE STANDARD TABLE OF string_table.
|
DATA lt_exp TYPE TABLE OF string_table.
|
||||||
DATA lt_tmp TYPE string_table.
|
DATA lt_tmp TYPE string_table.
|
||||||
DATA lo_nodes TYPE REF TO lcl_nodes_helper.
|
DATA lo_nodes TYPE REF TO lcl_nodes_helper.
|
||||||
|
|
||||||
|
@ -1659,8 +1706,8 @@ CLASS ltcl_json_to_abap IMPLEMENTATION.
|
||||||
METHOD to_abap_array_of_arrays.
|
METHOD to_abap_array_of_arrays.
|
||||||
|
|
||||||
DATA lo_cut TYPE REF TO lcl_json_to_abap.
|
DATA lo_cut TYPE REF TO lcl_json_to_abap.
|
||||||
DATA lt_mock TYPE STANDARD TABLE OF string_table.
|
DATA lt_mock TYPE TABLE OF string_table.
|
||||||
DATA lt_exp TYPE STANDARD TABLE OF string_table.
|
DATA lt_exp TYPE TABLE OF string_table.
|
||||||
DATA lt_tmp TYPE string_table.
|
DATA lt_tmp TYPE string_table.
|
||||||
DATA lo_nodes TYPE REF TO lcl_nodes_helper.
|
DATA lo_nodes TYPE REF TO lcl_nodes_helper.
|
||||||
|
|
||||||
|
@ -1859,6 +1906,173 @@ CLASS ltcl_json_to_abap IMPLEMENTATION.
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD to_abap_negative.
|
||||||
|
|
||||||
|
DATA lo_cut TYPE REF TO lcl_json_to_abap.
|
||||||
|
DATA lx TYPE REF TO z2ui5_cx_ajson_error.
|
||||||
|
DATA ls_mock TYPE ty_complex.
|
||||||
|
|
||||||
|
CREATE OBJECT lo_cut.
|
||||||
|
|
||||||
|
DATA lo_nodes TYPE REF TO lcl_nodes_helper.
|
||||||
|
|
||||||
|
TRY.
|
||||||
|
CREATE OBJECT lo_nodes.
|
||||||
|
lo_nodes->add( ' | |object | ' ).
|
||||||
|
lo_nodes->add( '/ |str |object | ' ).
|
||||||
|
|
||||||
|
lo_cut->to_abap(
|
||||||
|
EXPORTING
|
||||||
|
it_nodes = lo_nodes->sorted( )
|
||||||
|
CHANGING
|
||||||
|
c_container = ls_mock ).
|
||||||
|
cl_abap_unit_assert=>fail( ).
|
||||||
|
CATCH z2ui5_cx_ajson_error INTO lx.
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = lx->message
|
||||||
|
exp = 'Expected structure' ).
|
||||||
|
ENDTRY.
|
||||||
|
|
||||||
|
TRY.
|
||||||
|
CREATE OBJECT lo_nodes.
|
||||||
|
lo_nodes->add( ' | |object | ' ).
|
||||||
|
lo_nodes->add( '/ |str |array | ' ).
|
||||||
|
|
||||||
|
lo_cut->to_abap(
|
||||||
|
EXPORTING
|
||||||
|
it_nodes = lo_nodes->sorted( )
|
||||||
|
CHANGING
|
||||||
|
c_container = ls_mock ).
|
||||||
|
cl_abap_unit_assert=>fail( ).
|
||||||
|
CATCH z2ui5_cx_ajson_error INTO lx.
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = lx->message
|
||||||
|
exp = 'Expected table' ).
|
||||||
|
ENDTRY.
|
||||||
|
|
||||||
|
TRY.
|
||||||
|
CREATE OBJECT lo_nodes.
|
||||||
|
lo_nodes->add( ' | |object | ' ).
|
||||||
|
lo_nodes->add( '/ |int |str |hello ' ).
|
||||||
|
|
||||||
|
lo_cut->to_abap(
|
||||||
|
EXPORTING
|
||||||
|
it_nodes = lo_nodes->sorted( )
|
||||||
|
CHANGING
|
||||||
|
c_container = ls_mock ).
|
||||||
|
cl_abap_unit_assert=>fail( ).
|
||||||
|
CATCH z2ui5_cx_ajson_error INTO lx.
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = lx->message
|
||||||
|
exp = 'Source is not a number' ).
|
||||||
|
ENDTRY.
|
||||||
|
|
||||||
|
TRY.
|
||||||
|
CREATE OBJECT lo_nodes.
|
||||||
|
lo_nodes->add( ' | |object | ' ).
|
||||||
|
lo_nodes->add( '/ |date1 |str |baddate ' ).
|
||||||
|
|
||||||
|
lo_cut->to_abap(
|
||||||
|
EXPORTING
|
||||||
|
it_nodes = lo_nodes->sorted( )
|
||||||
|
CHANGING
|
||||||
|
c_container = ls_mock ).
|
||||||
|
cl_abap_unit_assert=>fail( ).
|
||||||
|
CATCH z2ui5_cx_ajson_error INTO lx.
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = lx->message
|
||||||
|
exp = 'Unexpected date format' ).
|
||||||
|
ENDTRY.
|
||||||
|
|
||||||
|
TRY.
|
||||||
|
CREATE OBJECT lo_nodes.
|
||||||
|
lo_nodes->add( ' | |object | ' ).
|
||||||
|
lo_nodes->add( '/ |missing |str |123 ' ).
|
||||||
|
|
||||||
|
lo_cut->to_abap(
|
||||||
|
EXPORTING
|
||||||
|
it_nodes = lo_nodes->sorted( )
|
||||||
|
CHANGING
|
||||||
|
c_container = ls_mock ).
|
||||||
|
cl_abap_unit_assert=>fail( ).
|
||||||
|
CATCH z2ui5_cx_ajson_error INTO lx.
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = lx->message
|
||||||
|
exp = 'Path not found' ).
|
||||||
|
ENDTRY.
|
||||||
|
|
||||||
|
TRY.
|
||||||
|
DATA lt_str TYPE string_table.
|
||||||
|
CREATE OBJECT lo_nodes.
|
||||||
|
lo_nodes->add( ' | |array | | ' ).
|
||||||
|
lo_nodes->add( '/ |a |str |hello |1' ).
|
||||||
|
|
||||||
|
lo_cut->to_abap(
|
||||||
|
EXPORTING
|
||||||
|
it_nodes = lo_nodes->sorted( )
|
||||||
|
CHANGING
|
||||||
|
c_container = lt_str ).
|
||||||
|
cl_abap_unit_assert=>fail( ).
|
||||||
|
CATCH z2ui5_cx_ajson_error INTO lx.
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = lx->message
|
||||||
|
exp = 'Need index to access tables' ).
|
||||||
|
ENDTRY.
|
||||||
|
|
||||||
|
TRY.
|
||||||
|
DATA lr_obj TYPE REF TO object.
|
||||||
|
CREATE OBJECT lo_nodes.
|
||||||
|
lo_nodes->add( ' | |str |hello | ' ).
|
||||||
|
|
||||||
|
lo_cut->to_abap(
|
||||||
|
EXPORTING
|
||||||
|
it_nodes = lo_nodes->sorted( )
|
||||||
|
CHANGING
|
||||||
|
c_container = lr_obj ).
|
||||||
|
cl_abap_unit_assert=>fail( ).
|
||||||
|
CATCH z2ui5_cx_ajson_error INTO lx.
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = lx->message
|
||||||
|
exp = 'Cannot assign to ref' ).
|
||||||
|
ENDTRY.
|
||||||
|
|
||||||
|
TRY.
|
||||||
|
DATA lr_data TYPE REF TO data.
|
||||||
|
CREATE OBJECT lo_nodes.
|
||||||
|
lo_nodes->add( ' | |str |hello | ' ).
|
||||||
|
|
||||||
|
lo_cut->to_abap(
|
||||||
|
EXPORTING
|
||||||
|
it_nodes = lo_nodes->sorted( )
|
||||||
|
CHANGING
|
||||||
|
c_container = lr_data ).
|
||||||
|
cl_abap_unit_assert=>fail( ).
|
||||||
|
CATCH z2ui5_cx_ajson_error INTO lx.
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = lx->message
|
||||||
|
exp = 'Cannot assign to ref' ).
|
||||||
|
ENDTRY.
|
||||||
|
|
||||||
|
TRY.
|
||||||
|
DATA lt_hashed TYPE HASHED TABLE OF string WITH UNIQUE KEY table_line.
|
||||||
|
CREATE OBJECT lo_nodes.
|
||||||
|
lo_nodes->add( ' | |array | | ' ).
|
||||||
|
lo_nodes->add( '/ |1 |str |One |1' ).
|
||||||
|
lo_nodes->add( '/ |2 |str |One |2' ).
|
||||||
|
|
||||||
|
lo_cut->to_abap(
|
||||||
|
EXPORTING
|
||||||
|
it_nodes = lo_nodes->sorted( )
|
||||||
|
CHANGING
|
||||||
|
c_container = lt_hashed ).
|
||||||
|
cl_abap_unit_assert=>fail( ).
|
||||||
|
CATCH z2ui5_cx_ajson_error INTO lx.
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = lx->message
|
||||||
|
exp = 'Duplicate insertion' ).
|
||||||
|
ENDTRY.
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
METHOD to_abap_corresponding.
|
METHOD to_abap_corresponding.
|
||||||
|
|
||||||
|
@ -1909,15 +2123,15 @@ CLASS ltcl_json_to_abap IMPLEMENTATION.
|
||||||
TRY.
|
TRY.
|
||||||
CREATE OBJECT lo_cut.
|
CREATE OBJECT lo_cut.
|
||||||
lo_cut->to_abap(
|
lo_cut->to_abap(
|
||||||
EXPORTING
|
EXPORTING
|
||||||
it_nodes = lo_nodes->sorted( )
|
it_nodes = lo_nodes->sorted( )
|
||||||
CHANGING
|
CHANGING
|
||||||
c_container = ls_act ).
|
c_container = ls_act ).
|
||||||
cl_abap_unit_assert=>fail( ).
|
cl_abap_unit_assert=>fail( ).
|
||||||
CATCH z2ui5_cx_ajson_error INTO lx.
|
CATCH z2ui5_cx_ajson_error INTO lx.
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = lx->message
|
act = lx->message
|
||||||
exp = 'Path not found' ).
|
exp = 'Path not found' ).
|
||||||
ENDTRY.
|
ENDTRY.
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
@ -1984,12 +2198,177 @@ CLASS ltcl_json_to_abap IMPLEMENTATION.
|
||||||
cl_abap_unit_assert=>fail( ).
|
cl_abap_unit_assert=>fail( ).
|
||||||
CATCH z2ui5_cx_ajson_error INTO lx.
|
CATCH z2ui5_cx_ajson_error INTO lx.
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = lx->message
|
act = lx->message
|
||||||
exp = 'Path not found' ).
|
exp = 'Path not found' ).
|
||||||
ENDTRY.
|
ENDTRY.
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD to_abap_compressed_stdrd.
|
||||||
|
|
||||||
|
TYPES: BEGIN OF ty_foo_bar,
|
||||||
|
foo TYPE string,
|
||||||
|
bar TYPE string,
|
||||||
|
END OF ty_foo_bar.
|
||||||
|
|
||||||
|
DATA lt_foo_bar TYPE STANDARD TABLE OF ty_foo_bar.
|
||||||
|
DATA ls_foo_bar LIKE LINE OF lt_foo_bar.
|
||||||
|
DATA lo_ajson TYPE REF TO z2ui5_cl_ajson.
|
||||||
|
DATA lv_json TYPE string.
|
||||||
|
|
||||||
|
lv_json =
|
||||||
|
'[' &&
|
||||||
|
' {' &&
|
||||||
|
' "foo": "abc",' &&
|
||||||
|
' "bar": "123"' &&
|
||||||
|
' },' &&
|
||||||
|
' {' &&
|
||||||
|
' "foo": "cde"' &&
|
||||||
|
' }' &&
|
||||||
|
']'.
|
||||||
|
|
||||||
|
lo_ajson = z2ui5_cl_ajson=>parse( lv_json ).
|
||||||
|
|
||||||
|
lo_ajson->to_abap( IMPORTING ev_container = lt_foo_bar ).
|
||||||
|
|
||||||
|
READ TABLE lt_foo_bar WITH KEY foo = 'cde' INTO ls_foo_bar.
|
||||||
|
|
||||||
|
cl_abap_unit_assert=>assert_initial( act = ls_foo_bar-bar ).
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD to_abap_compressed_stdrd_key.
|
||||||
|
|
||||||
|
TYPES: BEGIN OF ty_foo_bar,
|
||||||
|
foo TYPE string,
|
||||||
|
bar TYPE string,
|
||||||
|
END OF ty_foo_bar.
|
||||||
|
|
||||||
|
DATA lt_foo_bar TYPE STANDARD TABLE OF ty_foo_bar WITH NON-UNIQUE KEY foo.
|
||||||
|
DATA ls_foo_bar LIKE LINE OF lt_foo_bar.
|
||||||
|
DATA lo_ajson TYPE REF TO z2ui5_cl_ajson.
|
||||||
|
DATA lv_json TYPE string.
|
||||||
|
|
||||||
|
lv_json =
|
||||||
|
'[' &&
|
||||||
|
' {' &&
|
||||||
|
' "foo": "abc",' &&
|
||||||
|
' "bar": "123"' &&
|
||||||
|
' },' &&
|
||||||
|
' {' &&
|
||||||
|
' "foo": "cde"' &&
|
||||||
|
' }' &&
|
||||||
|
']'.
|
||||||
|
|
||||||
|
lo_ajson = z2ui5_cl_ajson=>parse( lv_json ).
|
||||||
|
|
||||||
|
lo_ajson->to_abap( IMPORTING ev_container = lt_foo_bar ).
|
||||||
|
|
||||||
|
READ TABLE lt_foo_bar WITH KEY foo = 'cde' INTO ls_foo_bar.
|
||||||
|
|
||||||
|
cl_abap_unit_assert=>assert_initial( act = ls_foo_bar-bar ).
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD to_abap_compressed_sort.
|
||||||
|
|
||||||
|
TYPES: BEGIN OF ty_foo_bar,
|
||||||
|
foo TYPE string,
|
||||||
|
bar TYPE string,
|
||||||
|
END OF ty_foo_bar.
|
||||||
|
|
||||||
|
DATA lt_foo_bar TYPE SORTED TABLE OF ty_foo_bar WITH NON-UNIQUE KEY foo.
|
||||||
|
DATA ls_foo_bar LIKE LINE OF lt_foo_bar.
|
||||||
|
DATA lo_ajson TYPE REF TO z2ui5_cl_ajson.
|
||||||
|
DATA lv_json TYPE string.
|
||||||
|
|
||||||
|
lv_json =
|
||||||
|
'[' &&
|
||||||
|
' {' &&
|
||||||
|
' "foo": "abc",' &&
|
||||||
|
' "bar": "123"' &&
|
||||||
|
' },' &&
|
||||||
|
' {' &&
|
||||||
|
' "foo": "cde"' &&
|
||||||
|
' }' &&
|
||||||
|
']'.
|
||||||
|
|
||||||
|
lo_ajson = z2ui5_cl_ajson=>parse( lv_json ).
|
||||||
|
|
||||||
|
lo_ajson->to_abap( IMPORTING ev_container = lt_foo_bar ).
|
||||||
|
|
||||||
|
READ TABLE lt_foo_bar WITH KEY foo = 'cde' INTO ls_foo_bar.
|
||||||
|
|
||||||
|
cl_abap_unit_assert=>assert_initial( act = ls_foo_bar-bar ).
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD to_abap_compressed_sort_unique.
|
||||||
|
|
||||||
|
TYPES: BEGIN OF ty_foo_bar,
|
||||||
|
foo TYPE string,
|
||||||
|
bar TYPE string,
|
||||||
|
END OF ty_foo_bar.
|
||||||
|
|
||||||
|
DATA lt_foo_bar TYPE SORTED TABLE OF ty_foo_bar WITH UNIQUE KEY foo.
|
||||||
|
DATA ls_foo_bar LIKE LINE OF lt_foo_bar.
|
||||||
|
DATA lo_ajson TYPE REF TO z2ui5_cl_ajson.
|
||||||
|
DATA lv_json TYPE string.
|
||||||
|
|
||||||
|
lv_json =
|
||||||
|
'[' &&
|
||||||
|
' {' &&
|
||||||
|
' "foo": "abc",' &&
|
||||||
|
' "bar": "123"' &&
|
||||||
|
' },' &&
|
||||||
|
' {' &&
|
||||||
|
' "foo": "cde"' &&
|
||||||
|
' }' &&
|
||||||
|
']'.
|
||||||
|
|
||||||
|
lo_ajson = z2ui5_cl_ajson=>parse( lv_json ).
|
||||||
|
|
||||||
|
lo_ajson->to_abap( IMPORTING ev_container = lt_foo_bar ).
|
||||||
|
|
||||||
|
READ TABLE lt_foo_bar WITH KEY foo = 'cde' INTO ls_foo_bar.
|
||||||
|
|
||||||
|
cl_abap_unit_assert=>assert_initial( act = ls_foo_bar-bar ).
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD to_abap_compressed_hash.
|
||||||
|
|
||||||
|
TYPES: BEGIN OF ty_foo_bar,
|
||||||
|
foo TYPE string,
|
||||||
|
bar TYPE string,
|
||||||
|
END OF ty_foo_bar.
|
||||||
|
|
||||||
|
DATA lt_foo_bar TYPE HASHED TABLE OF ty_foo_bar WITH UNIQUE KEY foo.
|
||||||
|
DATA ls_foo_bar LIKE LINE OF lt_foo_bar.
|
||||||
|
DATA lo_ajson TYPE REF TO z2ui5_cl_ajson.
|
||||||
|
DATA lv_json TYPE string.
|
||||||
|
|
||||||
|
lv_json =
|
||||||
|
'[' &&
|
||||||
|
' {' &&
|
||||||
|
' "foo": "abc",' &&
|
||||||
|
' "bar": "123"' &&
|
||||||
|
' },' &&
|
||||||
|
' {' &&
|
||||||
|
' "foo": "cde"' &&
|
||||||
|
' }' &&
|
||||||
|
']'.
|
||||||
|
|
||||||
|
lo_ajson = z2ui5_cl_ajson=>parse( lv_json ).
|
||||||
|
|
||||||
|
lo_ajson->to_abap( IMPORTING ev_container = lt_foo_bar ).
|
||||||
|
|
||||||
|
READ TABLE lt_foo_bar WITH KEY foo = 'cde' INTO ls_foo_bar.
|
||||||
|
|
||||||
|
cl_abap_unit_assert=>assert_initial( act = ls_foo_bar-bar ).
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
|
@ -2027,6 +2406,7 @@ CLASS ltcl_writer_test DEFINITION FINAL
|
||||||
METHODS read_only FOR TESTING RAISING z2ui5_cx_ajson_error.
|
METHODS read_only FOR TESTING RAISING z2ui5_cx_ajson_error.
|
||||||
METHODS set_array_obj FOR TESTING RAISING z2ui5_cx_ajson_error.
|
METHODS set_array_obj FOR TESTING RAISING z2ui5_cx_ajson_error.
|
||||||
METHODS set_with_type FOR TESTING RAISING z2ui5_cx_ajson_error.
|
METHODS set_with_type FOR TESTING RAISING z2ui5_cx_ajson_error.
|
||||||
|
METHODS new_array_w_keep_order_touch FOR TESTING RAISING z2ui5_cx_ajson_error.
|
||||||
METHODS overwrite_w_keep_order_touch FOR TESTING RAISING z2ui5_cx_ajson_error.
|
METHODS overwrite_w_keep_order_touch FOR TESTING RAISING z2ui5_cx_ajson_error.
|
||||||
METHODS overwrite_w_keep_order_set FOR TESTING RAISING z2ui5_cx_ajson_error.
|
METHODS overwrite_w_keep_order_set FOR TESTING RAISING z2ui5_cx_ajson_error.
|
||||||
METHODS setx FOR TESTING RAISING z2ui5_cx_ajson_error.
|
METHODS setx FOR TESTING RAISING z2ui5_cx_ajson_error.
|
||||||
|
@ -2036,9 +2416,9 @@ CLASS ltcl_writer_test DEFINITION FINAL
|
||||||
|
|
||||||
METHODS set_with_type_slice
|
METHODS set_with_type_slice
|
||||||
IMPORTING
|
IMPORTING
|
||||||
io_json_in TYPE REF TO z2ui5_cl_ajson
|
io_json_in TYPE REF TO z2ui5_cl_ajson
|
||||||
io_json_out TYPE REF TO z2ui5_if_ajson
|
io_json_out TYPE REF TO z2ui5_if_ajson
|
||||||
iv_path TYPE string
|
iv_path TYPE string
|
||||||
RAISING
|
RAISING
|
||||||
z2ui5_cx_ajson_error.
|
z2ui5_cx_ajson_error.
|
||||||
|
|
||||||
|
@ -2430,7 +2810,7 @@ CLASS ltcl_writer_test IMPLEMENTATION.
|
||||||
END OF ty_include,
|
END OF ty_include,
|
||||||
BEGIN OF ty_struct.
|
BEGIN OF ty_struct.
|
||||||
INCLUDE TYPE ty_include.
|
INCLUDE TYPE ty_include.
|
||||||
TYPES: dat TYPE xstring,
|
TYPES: dat TYPE xstring,
|
||||||
END OF ty_struct,
|
END OF ty_struct,
|
||||||
ty_tab TYPE STANDARD TABLE OF ty_struct WITH KEY str.
|
ty_tab TYPE STANDARD TABLE OF ty_struct WITH KEY str.
|
||||||
|
|
||||||
|
@ -2587,67 +2967,67 @@ CLASS ltcl_writer_test IMPLEMENTATION.
|
||||||
cl_abap_unit_assert=>fail( ).
|
cl_abap_unit_assert=>fail( ).
|
||||||
CATCH z2ui5_cx_ajson_error INTO lx.
|
CATCH z2ui5_cx_ajson_error INTO lx.
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = lx->message
|
act = lx->message
|
||||||
exp = 'Path [/a/1] already used and is not array' ).
|
exp = 'Path [/a/1] already used and is not array' ).
|
||||||
ENDTRY.
|
ENDTRY.
|
||||||
|
|
||||||
" push to not array
|
" push to not array
|
||||||
TRY.
|
TRY.
|
||||||
li_writer->push(
|
li_writer->push(
|
||||||
iv_path = '/a/1'
|
iv_path = '/a/1'
|
||||||
iv_val = 123 ).
|
iv_val = 123 ).
|
||||||
cl_abap_unit_assert=>fail( ).
|
cl_abap_unit_assert=>fail( ).
|
||||||
CATCH z2ui5_cx_ajson_error INTO lx.
|
CATCH z2ui5_cx_ajson_error INTO lx.
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = lx->message
|
act = lx->message
|
||||||
exp = 'Path [/a/1] is not array' ).
|
exp = 'Path [/a/1] is not array' ).
|
||||||
ENDTRY.
|
ENDTRY.
|
||||||
|
|
||||||
" push to not array
|
" push to not array
|
||||||
TRY.
|
TRY.
|
||||||
li_writer->push(
|
li_writer->push(
|
||||||
iv_path = '/x'
|
iv_path = '/x'
|
||||||
iv_val = 123 ).
|
iv_val = 123 ).
|
||||||
cl_abap_unit_assert=>fail( ).
|
cl_abap_unit_assert=>fail( ).
|
||||||
CATCH z2ui5_cx_ajson_error INTO lx.
|
CATCH z2ui5_cx_ajson_error INTO lx.
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = lx->message
|
act = lx->message
|
||||||
exp = 'Path [/x] does not exist' ).
|
exp = 'Path [/x] does not exist' ).
|
||||||
ENDTRY.
|
ENDTRY.
|
||||||
|
|
||||||
" set array item with non-numeric key
|
" set array item with non-numeric key
|
||||||
TRY.
|
TRY.
|
||||||
li_writer->set(
|
li_writer->set(
|
||||||
iv_path = '/a/abc/x'
|
iv_path = '/a/abc/x'
|
||||||
iv_val = 123 ).
|
iv_val = 123 ).
|
||||||
cl_abap_unit_assert=>fail( ).
|
cl_abap_unit_assert=>fail( ).
|
||||||
CATCH z2ui5_cx_ajson_error INTO lx.
|
CATCH z2ui5_cx_ajson_error INTO lx.
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = lx->message
|
act = lx->message
|
||||||
exp = 'Cannot add non-numeric key [abc] to array [/a/]' ).
|
exp = 'Cannot add non-numeric key [abc] to array [/a/]' ).
|
||||||
ENDTRY.
|
ENDTRY.
|
||||||
|
|
||||||
TRY.
|
TRY.
|
||||||
li_writer->set(
|
li_writer->set(
|
||||||
iv_path = '/a/abc'
|
iv_path = '/a/abc'
|
||||||
iv_val = 123 ).
|
iv_val = 123 ).
|
||||||
cl_abap_unit_assert=>fail( ).
|
cl_abap_unit_assert=>fail( ).
|
||||||
CATCH z2ui5_cx_ajson_error INTO lx.
|
CATCH z2ui5_cx_ajson_error INTO lx.
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = lx->message
|
act = lx->message
|
||||||
exp = 'Cannot add non-numeric key [abc] to array [/a/]' ).
|
exp = 'Cannot add non-numeric key [abc] to array [/a/]' ).
|
||||||
ENDTRY.
|
ENDTRY.
|
||||||
|
|
||||||
" set array item with zero key
|
" set array item with zero key
|
||||||
TRY.
|
TRY.
|
||||||
li_writer->set(
|
li_writer->set(
|
||||||
iv_path = '/a/0'
|
iv_path = '/a/0'
|
||||||
iv_val = 123 ).
|
iv_val = 123 ).
|
||||||
cl_abap_unit_assert=>fail( ).
|
cl_abap_unit_assert=>fail( ).
|
||||||
CATCH z2ui5_cx_ajson_error INTO lx.
|
CATCH z2ui5_cx_ajson_error INTO lx.
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = lx->message
|
act = lx->message
|
||||||
exp = 'Cannot add zero key to array [/a/]' ).
|
exp = 'Cannot add zero key to array [/a/]' ).
|
||||||
ENDTRY.
|
ENDTRY.
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
@ -2936,8 +3316,8 @@ CLASS ltcl_writer_test IMPLEMENTATION.
|
||||||
|
|
||||||
TRY.
|
TRY.
|
||||||
li_writer->set(
|
li_writer->set(
|
||||||
iv_path = '/c'
|
iv_path = '/c'
|
||||||
iv_val = 'abc' ).
|
iv_val = 'abc' ).
|
||||||
cl_abap_unit_assert=>fail( ).
|
cl_abap_unit_assert=>fail( ).
|
||||||
CATCH z2ui5_cx_ajson_error.
|
CATCH z2ui5_cx_ajson_error.
|
||||||
ENDTRY.
|
ENDTRY.
|
||||||
|
@ -2950,8 +3330,8 @@ CLASS ltcl_writer_test IMPLEMENTATION.
|
||||||
|
|
||||||
TRY.
|
TRY.
|
||||||
li_writer->push(
|
li_writer->push(
|
||||||
iv_path = '/b'
|
iv_path = '/b'
|
||||||
iv_val = 'xyz' ).
|
iv_val = 'xyz' ).
|
||||||
cl_abap_unit_assert=>fail( ).
|
cl_abap_unit_assert=>fail( ).
|
||||||
CATCH z2ui5_cx_ajson_error.
|
CATCH z2ui5_cx_ajson_error.
|
||||||
ENDTRY.
|
ENDTRY.
|
||||||
|
@ -3100,6 +3480,37 @@ CLASS ltcl_writer_test IMPLEMENTATION.
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
METHOD new_array_w_keep_order_touch.
|
||||||
|
|
||||||
|
DATA li_cut TYPE REF TO z2ui5_if_ajson.
|
||||||
|
|
||||||
|
" default order adds new arrays at beginning of node (pos 0)
|
||||||
|
li_cut = z2ui5_cl_ajson=>create_empty(
|
||||||
|
)->set(
|
||||||
|
iv_path = '/b'
|
||||||
|
iv_val = 1 ).
|
||||||
|
|
||||||
|
li_cut->touch_array( '/a' ).
|
||||||
|
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = li_cut->stringify( )
|
||||||
|
exp = '{"a":[],"b":1}' ).
|
||||||
|
|
||||||
|
" with keep order, new array is created at end of node
|
||||||
|
li_cut = z2ui5_cl_ajson=>create_empty(
|
||||||
|
)->keep_item_order(
|
||||||
|
)->set(
|
||||||
|
iv_path = '/b'
|
||||||
|
iv_val = 1 ).
|
||||||
|
|
||||||
|
li_cut->touch_array( '/a' ).
|
||||||
|
|
||||||
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
act = li_cut->stringify( )
|
||||||
|
exp = '{"b":1,"a":[]}' ).
|
||||||
|
|
||||||
|
ENDMETHOD.
|
||||||
|
|
||||||
METHOD overwrite_w_keep_order_touch.
|
METHOD overwrite_w_keep_order_touch.
|
||||||
|
|
||||||
DATA li_cut TYPE REF TO z2ui5_if_ajson.
|
DATA li_cut TYPE REF TO z2ui5_if_ajson.
|
||||||
|
@ -3313,22 +3724,22 @@ CLASS ltcl_integrated DEFINITION
|
||||||
col TYPE i,
|
col TYPE i,
|
||||||
END OF ty_loc,
|
END OF ty_loc,
|
||||||
BEGIN OF ty_issue,
|
BEGIN OF ty_issue,
|
||||||
message TYPE string,
|
message TYPE string,
|
||||||
key TYPE string,
|
key TYPE string,
|
||||||
filename TYPE string,
|
filename TYPE string,
|
||||||
start TYPE ty_loc,
|
start TYPE ty_loc,
|
||||||
end TYPE ty_loc,
|
end TYPE ty_loc,
|
||||||
END OF ty_issue,
|
END OF ty_issue,
|
||||||
tt_issues TYPE STANDARD TABLE OF ty_issue WITH KEY message key,
|
tt_issues TYPE STANDARD TABLE OF ty_issue WITH KEY message key,
|
||||||
BEGIN OF ty_target,
|
BEGIN OF ty_target,
|
||||||
string TYPE string,
|
string TYPE string,
|
||||||
number TYPE i,
|
number TYPE i,
|
||||||
float TYPE f,
|
float TYPE f,
|
||||||
boolean TYPE abap_bool,
|
boolean TYPE abap_bool,
|
||||||
false TYPE abap_bool,
|
false TYPE abap_bool,
|
||||||
null TYPE string,
|
null TYPE string,
|
||||||
date TYPE string, " ??? TODO
|
date TYPE string, " ??? TODO
|
||||||
issues TYPE tt_issues,
|
issues TYPE tt_issues,
|
||||||
END OF ty_target.
|
END OF ty_target.
|
||||||
|
|
||||||
METHODS reader FOR TESTING RAISING z2ui5_cx_ajson_error.
|
METHODS reader FOR TESTING RAISING z2ui5_cx_ajson_error.
|
||||||
|
@ -3374,8 +3785,8 @@ CLASS ltcl_integrated IMPLEMENTATION.
|
||||||
|
|
||||||
METHOD array_index.
|
METHOD array_index.
|
||||||
|
|
||||||
DATA lt_act TYPE STANDARD TABLE OF ty_loc.
|
DATA lt_act TYPE TABLE OF ty_loc.
|
||||||
DATA lt_exp TYPE STANDARD TABLE OF ty_loc.
|
DATA lt_exp TYPE TABLE OF ty_loc.
|
||||||
DATA ls_exp TYPE ty_loc.
|
DATA ls_exp TYPE ty_loc.
|
||||||
|
|
||||||
DATA lv_src TYPE string.
|
DATA lv_src TYPE string.
|
||||||
|
@ -3542,9 +3953,9 @@ CLASS ltcl_integrated IMPLEMENTATION.
|
||||||
|
|
||||||
DATA:
|
DATA:
|
||||||
BEGIN OF ls_dummy,
|
BEGIN OF ls_dummy,
|
||||||
zulu TYPE string,
|
zulu TYPE string,
|
||||||
alpha TYPE string,
|
alpha TYPE string,
|
||||||
beta TYPE string,
|
beta TYPE string,
|
||||||
END OF ls_dummy.
|
END OF ls_dummy.
|
||||||
|
|
||||||
DATA lv_act TYPE string.
|
DATA lv_act TYPE string.
|
||||||
|
@ -3687,18 +4098,18 @@ CLASS ltcl_abap_to_json DEFINITION
|
||||||
tt_struc TYPE STANDARD TABLE OF ty_struc WITH KEY a,
|
tt_struc TYPE STANDARD TABLE OF ty_struc WITH KEY a,
|
||||||
BEGIN OF ty_struc_complex.
|
BEGIN OF ty_struc_complex.
|
||||||
INCLUDE TYPE ty_struc.
|
INCLUDE TYPE ty_struc.
|
||||||
TYPES:
|
TYPES:
|
||||||
el TYPE string,
|
el TYPE string,
|
||||||
struc TYPE ty_struc,
|
struc TYPE ty_struc,
|
||||||
tab TYPE tt_struc,
|
tab TYPE tt_struc,
|
||||||
stab TYPE string_table,
|
stab TYPE string_table,
|
||||||
END OF ty_struc_complex.
|
END OF ty_struc_complex.
|
||||||
|
|
||||||
TYPES
|
TYPES
|
||||||
BEGIN OF ty_named_include.
|
BEGIN OF ty_named_include.
|
||||||
INCLUDE TYPE ty_struc AS named_with_suffix RENAMING WITH SUFFIX _suf.
|
INCLUDE TYPE ty_struc AS named_with_suffix RENAMING WITH SUFFIX _suf.
|
||||||
TYPES:
|
TYPES:
|
||||||
el TYPE string,
|
el TYPE string,
|
||||||
END OF ty_named_include.
|
END OF ty_named_include.
|
||||||
|
|
||||||
METHODS set_ajson FOR TESTING RAISING z2ui5_cx_ajson_error.
|
METHODS set_ajson FOR TESTING RAISING z2ui5_cx_ajson_error.
|
||||||
|
@ -4027,7 +4438,7 @@ CLASS ltcl_abap_to_json IMPLEMENTATION.
|
||||||
DATA lo_nodes_exp TYPE REF TO lcl_nodes_helper.
|
DATA lo_nodes_exp TYPE REF TO lcl_nodes_helper.
|
||||||
DATA lt_nodes TYPE z2ui5_if_ajson_types=>ty_nodes_tt.
|
DATA lt_nodes TYPE z2ui5_if_ajson_types=>ty_nodes_tt.
|
||||||
|
|
||||||
DATA lt_tab TYPE STANDARD TABLE OF ty_struc.
|
DATA lt_tab TYPE TABLE OF ty_struc.
|
||||||
FIELD-SYMBOLS <s> LIKE LINE OF lt_tab.
|
FIELD-SYMBOLS <s> LIKE LINE OF lt_tab.
|
||||||
|
|
||||||
APPEND INITIAL LINE TO lt_tab ASSIGNING <s>.
|
APPEND INITIAL LINE TO lt_tab ASSIGNING <s>.
|
||||||
|
@ -4095,7 +4506,7 @@ CLASS ltcl_filter_test DEFINITION FINAL
|
||||||
type TYPE z2ui5_if_ajson_filter=>ty_visit_type,
|
type TYPE z2ui5_if_ajson_filter=>ty_visit_type,
|
||||||
END OF ty_visit_history.
|
END OF ty_visit_history.
|
||||||
|
|
||||||
DATA mt_visit_history TYPE STANDARD TABLE OF ty_visit_history.
|
DATA mt_visit_history TYPE TABLE OF ty_visit_history.
|
||||||
|
|
||||||
METHODS simple_test FOR TESTING RAISING z2ui5_cx_ajson_error.
|
METHODS simple_test FOR TESTING RAISING z2ui5_cx_ajson_error.
|
||||||
METHODS array_test FOR TESTING RAISING z2ui5_cx_ajson_error.
|
METHODS array_test FOR TESTING RAISING z2ui5_cx_ajson_error.
|
||||||
|
@ -4422,13 +4833,13 @@ CLASS ltcl_mapper_test IMPLEMENTATION.
|
||||||
|
|
||||||
TRY.
|
TRY.
|
||||||
z2ui5_cl_ajson=>create_from(
|
z2ui5_cl_ajson=>create_from(
|
||||||
ii_source_json = lo_json
|
ii_source_json = lo_json
|
||||||
ii_mapper = me ).
|
ii_mapper = me ).
|
||||||
cl_abap_unit_assert=>fail( ).
|
cl_abap_unit_assert=>fail( ).
|
||||||
CATCH z2ui5_cx_ajson_error INTO lx_err.
|
CATCH z2ui5_cx_ajson_error INTO lx_err.
|
||||||
cl_abap_unit_assert=>assert_char_cp(
|
cl_abap_unit_assert=>assert_char_cp(
|
||||||
act = lx_err->get_text( )
|
act = lx_err->get_text( )
|
||||||
exp = 'Renamed node has a duplicate @/AB' ).
|
exp = 'Renamed node has a duplicate @/AB' ).
|
||||||
ENDTRY.
|
ENDTRY.
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
@ -4472,13 +4883,13 @@ CLASS ltcl_mapper_test IMPLEMENTATION.
|
||||||
|
|
||||||
TRY.
|
TRY.
|
||||||
z2ui5_cl_ajson=>create_from(
|
z2ui5_cl_ajson=>create_from(
|
||||||
ii_source_json = lo_json
|
ii_source_json = lo_json
|
||||||
ii_mapper = me ).
|
ii_mapper = me ).
|
||||||
cl_abap_unit_assert=>fail( ).
|
cl_abap_unit_assert=>fail( ).
|
||||||
CATCH z2ui5_cx_ajson_error INTO lx_err.
|
CATCH z2ui5_cx_ajson_error INTO lx_err.
|
||||||
cl_abap_unit_assert=>assert_char_cp(
|
cl_abap_unit_assert=>assert_char_cp(
|
||||||
act = lx_err->get_text( )
|
act = lx_err->get_text( )
|
||||||
exp = 'Renamed node name cannot be empty @/set_this_empty' ).
|
exp = 'Renamed node name cannot be empty @/set_this_empty' ).
|
||||||
ENDTRY.
|
ENDTRY.
|
||||||
|
|
||||||
ENDMETHOD.
|
ENDMETHOD.
|
||||||
|
|
|
@ -1,58 +1,58 @@
|
||||||
class Z2UI5_CL_AJSON_FILTER_LIB definition
|
CLASS z2ui5_cl_ajson_filter_lib DEFINITION
|
||||||
public
|
PUBLIC
|
||||||
final
|
FINAL
|
||||||
create public .
|
CREATE PUBLIC .
|
||||||
|
|
||||||
public section.
|
PUBLIC SECTION.
|
||||||
|
|
||||||
class-methods create_empty_filter
|
CLASS-METHODS create_empty_filter
|
||||||
returning
|
RETURNING
|
||||||
value(ri_filter) type ref to z2ui5_if_ajson_filter
|
VALUE(ri_filter) TYPE REF TO z2ui5_if_ajson_filter
|
||||||
raising
|
RAISING
|
||||||
z2UI5_cx_ajson_error .
|
z2ui5_cx_ajson_error .
|
||||||
class-methods create_path_filter
|
CLASS-METHODS create_path_filter
|
||||||
importing
|
IMPORTING
|
||||||
!it_skip_paths type string_table optional
|
!it_skip_paths TYPE string_table OPTIONAL
|
||||||
!iv_skip_paths type string optional
|
!iv_skip_paths TYPE string OPTIONAL
|
||||||
!iv_pattern_search type abap_bool default abap_false
|
!iv_pattern_search TYPE abap_bool DEFAULT abap_false
|
||||||
returning
|
RETURNING
|
||||||
value(ri_filter) type ref to z2ui5_if_ajson_filter
|
VALUE(ri_filter) TYPE REF TO z2ui5_if_ajson_filter
|
||||||
raising
|
RAISING
|
||||||
z2UI5_cx_ajson_error .
|
z2ui5_cx_ajson_error .
|
||||||
class-methods create_and_filter
|
CLASS-METHODS create_and_filter
|
||||||
importing
|
IMPORTING
|
||||||
!it_filters type z2ui5_if_ajson_filter=>ty_filter_tab
|
!it_filters TYPE z2ui5_if_ajson_filter=>ty_filter_tab
|
||||||
returning
|
RETURNING
|
||||||
value(ri_filter) type ref to z2ui5_if_ajson_filter
|
VALUE(ri_filter) TYPE REF TO z2ui5_if_ajson_filter
|
||||||
raising
|
RAISING
|
||||||
z2UI5_cx_ajson_error .
|
z2ui5_cx_ajson_error .
|
||||||
|
|
||||||
protected section.
|
PROTECTED SECTION.
|
||||||
private section.
|
PRIVATE SECTION.
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CLASS Z2UI5_CL_AJSON_FILTER_LIB IMPLEMENTATION.
|
CLASS z2ui5_cl_ajson_filter_lib IMPLEMENTATION.
|
||||||
|
|
||||||
|
|
||||||
method create_and_filter.
|
METHOD create_and_filter.
|
||||||
create object ri_filter type lcl_and_filter
|
CREATE OBJECT ri_filter TYPE lcl_and_filter
|
||||||
exporting
|
EXPORTING
|
||||||
it_filters = it_filters.
|
it_filters = it_filters.
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method create_empty_filter.
|
METHOD create_empty_filter.
|
||||||
create object ri_filter type lcl_empty_filter.
|
CREATE OBJECT ri_filter TYPE lcl_empty_filter.
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method create_path_filter.
|
METHOD create_path_filter.
|
||||||
create object ri_filter type lcl_paths_filter
|
CREATE OBJECT ri_filter TYPE lcl_paths_filter
|
||||||
exporting
|
EXPORTING
|
||||||
iv_pattern_search = iv_pattern_search
|
iv_pattern_search = iv_pattern_search
|
||||||
it_skip_paths = it_skip_paths
|
it_skip_paths = it_skip_paths
|
||||||
iv_skip_paths = iv_skip_paths.
|
iv_skip_paths = iv_skip_paths.
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
|
@ -2,143 +2,143 @@
|
||||||
* FILTER EMPTY VALUES
|
* FILTER EMPTY VALUES
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
|
|
||||||
class lcl_empty_filter definition final.
|
CLASS lcl_empty_filter DEFINITION FINAL.
|
||||||
public section.
|
PUBLIC SECTION.
|
||||||
interfaces z2ui5_if_ajson_filter.
|
INTERFACES z2ui5_if_ajson_filter.
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
||||||
class lcl_empty_filter implementation.
|
CLASS lcl_empty_filter IMPLEMENTATION.
|
||||||
method z2ui5_if_ajson_filter~keep_node.
|
METHOD z2ui5_if_ajson_filter~keep_node.
|
||||||
|
|
||||||
rv_keep = boolc(
|
rv_keep = boolc(
|
||||||
( iv_visit = z2ui5_if_ajson_filter=>visit_type-value and is_node-value is not initial ) or
|
( iv_visit = z2ui5_if_ajson_filter=>visit_type-value AND is_node-value IS NOT INITIAL ) OR
|
||||||
( iv_visit <> z2ui5_if_ajson_filter=>visit_type-value and is_node-children > 0 ) ).
|
( iv_visit <> z2ui5_if_ajson_filter=>visit_type-value AND is_node-children > 0 ) ).
|
||||||
" children = 0 on open for initially empty nodes and on close for filtered ones
|
" children = 0 on open for initially empty nodes and on close for filtered ones
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
* FILTER PREDEFINED PATHS
|
* FILTER PREDEFINED PATHS
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
|
|
||||||
class lcl_paths_filter definition final.
|
CLASS lcl_paths_filter DEFINITION FINAL.
|
||||||
public section.
|
PUBLIC SECTION.
|
||||||
interfaces z2ui5_if_ajson_filter.
|
INTERFACES z2ui5_if_ajson_filter.
|
||||||
methods constructor
|
METHODS constructor
|
||||||
importing
|
IMPORTING
|
||||||
it_skip_paths type string_table optional
|
it_skip_paths TYPE string_table OPTIONAL
|
||||||
iv_skip_paths type string optional
|
iv_skip_paths TYPE string OPTIONAL
|
||||||
iv_pattern_search type abap_bool
|
iv_pattern_search TYPE abap_bool
|
||||||
raising
|
RAISING
|
||||||
z2UI5_cx_ajson_error.
|
z2ui5_cx_ajson_error.
|
||||||
private section.
|
PRIVATE SECTION.
|
||||||
data mt_skip_paths type hashed table of string with unique key table_line.
|
DATA mt_skip_paths TYPE HASHED TABLE OF string WITH UNIQUE KEY table_line.
|
||||||
data mv_pattern_search type abap_bool.
|
DATA mv_pattern_search TYPE abap_bool.
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
||||||
class lcl_paths_filter implementation.
|
CLASS lcl_paths_filter IMPLEMENTATION.
|
||||||
|
|
||||||
method z2ui5_if_ajson_filter~keep_node.
|
METHOD z2ui5_if_ajson_filter~keep_node.
|
||||||
|
|
||||||
data lv_full_path type string.
|
DATA lv_full_path TYPE string.
|
||||||
field-symbols <p> like line of mt_skip_paths.
|
FIELD-SYMBOLS <p> LIKE LINE OF mt_skip_paths.
|
||||||
|
|
||||||
lv_full_path = is_node-path && is_node-name.
|
lv_full_path = is_node-path && is_node-name.
|
||||||
|
|
||||||
if mv_pattern_search = abap_true.
|
IF mv_pattern_search = abap_true.
|
||||||
rv_keep = abap_true.
|
rv_keep = abap_true.
|
||||||
loop at mt_skip_paths assigning <p>.
|
LOOP AT mt_skip_paths ASSIGNING <p>.
|
||||||
if lv_full_path cp <p>.
|
IF lv_full_path CP <p>.
|
||||||
rv_keep = abap_false.
|
rv_keep = abap_false.
|
||||||
exit.
|
EXIT.
|
||||||
endif.
|
ENDIF.
|
||||||
endloop.
|
ENDLOOP.
|
||||||
else.
|
ELSE.
|
||||||
read table mt_skip_paths with key table_line = lv_full_path transporting no fields.
|
READ TABLE mt_skip_paths WITH KEY table_line = lv_full_path TRANSPORTING NO FIELDS.
|
||||||
rv_keep = boolc( sy-subrc <> 0 ).
|
rv_keep = boolc( sy-subrc <> 0 ).
|
||||||
endif.
|
ENDIF.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method constructor.
|
METHOD constructor.
|
||||||
|
|
||||||
data lv_s type string.
|
DATA lv_s TYPE string.
|
||||||
data lt_tab type string_table.
|
DATA lt_tab TYPE string_table.
|
||||||
field-symbols <s> type string.
|
FIELD-SYMBOLS <s> TYPE string.
|
||||||
|
|
||||||
if boolc( iv_skip_paths is initial ) = boolc( it_skip_paths is initial ). " XOR
|
IF boolc( iv_skip_paths IS INITIAL ) = boolc( it_skip_paths IS INITIAL ). " XOR
|
||||||
z2UI5_cx_ajson_error=>raise( 'no filter path specified' ).
|
z2ui5_cx_ajson_error=>raise( 'no filter path specified' ).
|
||||||
endif.
|
ENDIF.
|
||||||
|
|
||||||
loop at it_skip_paths into lv_s.
|
LOOP AT it_skip_paths INTO lv_s.
|
||||||
lv_s = to_lower( lv_s ).
|
lv_s = to_lower( lv_s ).
|
||||||
append lv_s to lt_tab.
|
APPEND lv_s TO lt_tab.
|
||||||
endloop.
|
ENDLOOP.
|
||||||
|
|
||||||
if iv_skip_paths is not initial.
|
IF iv_skip_paths IS NOT INITIAL.
|
||||||
split iv_skip_paths at ',' into table lt_tab.
|
SPLIT iv_skip_paths AT ',' INTO TABLE lt_tab.
|
||||||
loop at lt_tab assigning <s>.
|
LOOP AT lt_tab ASSIGNING <s>.
|
||||||
if <s> is initial.
|
IF <s> IS INITIAL.
|
||||||
delete lt_tab index sy-tabix.
|
DELETE lt_tab INDEX sy-tabix.
|
||||||
continue.
|
CONTINUE.
|
||||||
endif.
|
ENDIF.
|
||||||
<s> = condense( to_lower( <s> ) ).
|
<s> = condense( to_lower( <s> ) ).
|
||||||
endloop.
|
ENDLOOP.
|
||||||
endif.
|
ENDIF.
|
||||||
|
|
||||||
sort lt_tab by table_line.
|
SORT lt_tab BY table_line.
|
||||||
delete adjacent duplicates from lt_tab.
|
DELETE ADJACENT DUPLICATES FROM lt_tab.
|
||||||
|
|
||||||
mt_skip_paths = lt_tab.
|
mt_skip_paths = lt_tab.
|
||||||
mv_pattern_search = iv_pattern_search.
|
mv_pattern_search = iv_pattern_search.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
* MULTI FILTER
|
* MULTI FILTER
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
|
|
||||||
class lcl_and_filter definition final.
|
CLASS lcl_and_filter DEFINITION FINAL.
|
||||||
public section.
|
PUBLIC SECTION.
|
||||||
interfaces z2ui5_if_ajson_filter.
|
INTERFACES z2ui5_if_ajson_filter.
|
||||||
methods constructor
|
METHODS constructor
|
||||||
importing
|
IMPORTING
|
||||||
it_filters type z2ui5_if_ajson_filter=>ty_filter_tab
|
it_filters TYPE z2ui5_if_ajson_filter=>ty_filter_tab
|
||||||
raising
|
RAISING
|
||||||
z2UI5_cx_ajson_error.
|
z2ui5_cx_ajson_error.
|
||||||
private section.
|
PRIVATE SECTION.
|
||||||
data mt_filters type z2ui5_if_ajson_filter=>ty_filter_tab.
|
DATA mt_filters TYPE z2ui5_if_ajson_filter=>ty_filter_tab.
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
||||||
class lcl_and_filter implementation.
|
CLASS lcl_and_filter IMPLEMENTATION.
|
||||||
|
|
||||||
method z2ui5_if_ajson_filter~keep_node.
|
METHOD z2ui5_if_ajson_filter~keep_node.
|
||||||
|
|
||||||
data li_filter like line of mt_filters.
|
DATA li_filter LIKE LINE OF mt_filters.
|
||||||
|
|
||||||
rv_keep = abap_true.
|
rv_keep = abap_true.
|
||||||
loop at mt_filters into li_filter.
|
LOOP AT mt_filters INTO li_filter.
|
||||||
rv_keep = li_filter->keep_node(
|
rv_keep = li_filter->keep_node(
|
||||||
is_node = is_node
|
is_node = is_node
|
||||||
iv_visit = iv_visit ).
|
iv_visit = iv_visit ).
|
||||||
if rv_keep = abap_false.
|
IF rv_keep = abap_false.
|
||||||
return.
|
RETURN.
|
||||||
endif.
|
ENDIF.
|
||||||
endloop.
|
ENDLOOP.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method constructor.
|
METHOD constructor.
|
||||||
|
|
||||||
data li_filter like line of it_filters.
|
DATA li_filter LIKE LINE OF it_filters.
|
||||||
|
|
||||||
loop at it_filters into li_filter where table_line is bound.
|
LOOP AT it_filters INTO li_filter WHERE table_line IS BOUND.
|
||||||
append li_filter to mt_filters.
|
APPEND li_filter TO mt_filters.
|
||||||
endloop.
|
ENDLOOP.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
class ltcl_filters_test definition final
|
CLASS ltcl_filters_test DEFINITION FINAL
|
||||||
for testing
|
FOR TESTING
|
||||||
risk level harmless
|
RISK LEVEL HARMLESS
|
||||||
duration short.
|
DURATION SHORT.
|
||||||
private section.
|
PRIVATE SECTION.
|
||||||
methods empty_filter_simple for testing raising z2UI5_cx_ajson_error.
|
METHODS empty_filter_simple FOR TESTING RAISING z2ui5_cx_ajson_error.
|
||||||
methods empty_filter_deep for testing raising z2UI5_cx_ajson_error.
|
METHODS empty_filter_deep FOR TESTING RAISING z2ui5_cx_ajson_error.
|
||||||
methods path_filter for testing raising z2UI5_cx_ajson_error.
|
METHODS path_filter FOR TESTING RAISING z2ui5_cx_ajson_error.
|
||||||
methods path_filter_string for testing raising z2UI5_cx_ajson_error.
|
METHODS path_filter_string FOR TESTING RAISING z2ui5_cx_ajson_error.
|
||||||
methods path_filter_w_patterns for testing raising z2UI5_cx_ajson_error.
|
METHODS path_filter_w_patterns FOR TESTING RAISING z2ui5_cx_ajson_error.
|
||||||
methods path_filter_deep for testing raising z2UI5_cx_ajson_error.
|
METHODS path_filter_deep FOR TESTING RAISING z2ui5_cx_ajson_error.
|
||||||
methods and_filter for testing raising z2UI5_cx_ajson_error.
|
METHODS and_filter FOR TESTING RAISING z2ui5_cx_ajson_error.
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
class ltcl_filters_test implementation.
|
CLASS ltcl_filters_test IMPLEMENTATION.
|
||||||
|
|
||||||
method empty_filter_simple.
|
METHOD empty_filter_simple.
|
||||||
|
|
||||||
data li_json type ref to z2ui5_if_ajson.
|
DATA li_json TYPE REF TO z2ui5_if_ajson.
|
||||||
data li_json_filtered type ref to z2ui5_if_ajson.
|
DATA li_json_filtered TYPE REF TO z2ui5_if_ajson.
|
||||||
|
|
||||||
li_json = z2ui5_cl_ajson=>create_empty( ).
|
li_json = z2ui5_cl_ajson=>create_empty( ).
|
||||||
li_json->set(
|
li_json->set(
|
||||||
|
@ -42,12 +42,12 @@ class ltcl_filters_test implementation.
|
||||||
act = li_json_filtered->stringify( )
|
act = li_json_filtered->stringify( )
|
||||||
exp = '{"a":"1","c":"3"}' ).
|
exp = '{"a":"1","c":"3"}' ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method empty_filter_deep.
|
METHOD empty_filter_deep.
|
||||||
|
|
||||||
data li_json type ref to z2ui5_if_ajson.
|
DATA li_json TYPE REF TO z2ui5_if_ajson.
|
||||||
data li_json_filtered type ref to z2ui5_if_ajson.
|
DATA li_json_filtered TYPE REF TO z2ui5_if_ajson.
|
||||||
|
|
||||||
li_json = z2ui5_cl_ajson=>create_empty( ).
|
li_json = z2ui5_cl_ajson=>create_empty( ).
|
||||||
li_json->set(
|
li_json->set(
|
||||||
|
@ -71,15 +71,15 @@ class ltcl_filters_test implementation.
|
||||||
act = li_json_filtered->stringify( )
|
act = li_json_filtered->stringify( )
|
||||||
exp = '{"a":"1"}' ).
|
exp = '{"a":"1"}' ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method path_filter.
|
METHOD path_filter.
|
||||||
|
|
||||||
data li_json type ref to z2ui5_if_ajson.
|
DATA li_json TYPE REF TO z2ui5_if_ajson.
|
||||||
data li_json_filtered type ref to z2ui5_if_ajson.
|
DATA li_json_filtered TYPE REF TO z2ui5_if_ajson.
|
||||||
data lt_paths type string_table.
|
DATA lt_paths TYPE string_table.
|
||||||
|
|
||||||
append '/b/c' to lt_paths.
|
APPEND '/b/c' TO lt_paths.
|
||||||
|
|
||||||
li_json = z2ui5_cl_ajson=>create_empty( ).
|
li_json = z2ui5_cl_ajson=>create_empty( ).
|
||||||
li_json->set(
|
li_json->set(
|
||||||
|
@ -100,12 +100,12 @@ class ltcl_filters_test implementation.
|
||||||
act = li_json_filtered->stringify( )
|
act = li_json_filtered->stringify( )
|
||||||
exp = '{"a":"1","b":{},"c":{"d":"3"}}' ).
|
exp = '{"a":"1","b":{},"c":{"d":"3"}}' ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method path_filter_string.
|
METHOD path_filter_string.
|
||||||
|
|
||||||
data li_json type ref to z2ui5_if_ajson.
|
DATA li_json TYPE REF TO z2ui5_if_ajson.
|
||||||
data li_json_filtered type ref to z2ui5_if_ajson.
|
DATA li_json_filtered TYPE REF TO z2ui5_if_ajson.
|
||||||
|
|
||||||
li_json = z2ui5_cl_ajson=>create_empty( ).
|
li_json = z2ui5_cl_ajson=>create_empty( ).
|
||||||
li_json->set(
|
li_json->set(
|
||||||
|
@ -126,12 +126,12 @@ class ltcl_filters_test implementation.
|
||||||
act = li_json_filtered->stringify( )
|
act = li_json_filtered->stringify( )
|
||||||
exp = '{"a":"1","b":{},"c":{}}' ).
|
exp = '{"a":"1","b":{},"c":{}}' ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method path_filter_w_patterns.
|
METHOD path_filter_w_patterns.
|
||||||
|
|
||||||
data li_json type ref to z2ui5_if_ajson.
|
DATA li_json TYPE REF TO z2ui5_if_ajson.
|
||||||
data li_json_filtered type ref to z2ui5_if_ajson.
|
DATA li_json_filtered TYPE REF TO z2ui5_if_ajson.
|
||||||
|
|
||||||
li_json = z2ui5_cl_ajson=>create_empty( ).
|
li_json = z2ui5_cl_ajson=>create_empty( ).
|
||||||
li_json->set(
|
li_json->set(
|
||||||
|
@ -160,15 +160,15 @@ class ltcl_filters_test implementation.
|
||||||
act = li_json_filtered->stringify( )
|
act = li_json_filtered->stringify( )
|
||||||
exp = '{"a":"1","b":{},"c":{"d":"3"}}' ).
|
exp = '{"a":"1","b":{},"c":{"d":"3"}}' ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method path_filter_deep.
|
METHOD path_filter_deep.
|
||||||
|
|
||||||
data li_json type ref to z2ui5_if_ajson.
|
DATA li_json TYPE REF TO z2ui5_if_ajson.
|
||||||
data li_json_filtered type ref to z2ui5_if_ajson.
|
DATA li_json_filtered TYPE REF TO z2ui5_if_ajson.
|
||||||
data lt_paths type string_table.
|
DATA lt_paths TYPE string_table.
|
||||||
|
|
||||||
append '/b' to lt_paths.
|
APPEND '/b' TO lt_paths.
|
||||||
|
|
||||||
li_json = z2ui5_cl_ajson=>create_empty( ).
|
li_json = z2ui5_cl_ajson=>create_empty( ).
|
||||||
li_json->set(
|
li_json->set(
|
||||||
|
@ -192,16 +192,16 @@ class ltcl_filters_test implementation.
|
||||||
act = li_json_filtered->stringify( )
|
act = li_json_filtered->stringify( )
|
||||||
exp = '{"a":"1","c":{"d":"3"}}' ).
|
exp = '{"a":"1","c":{"d":"3"}}' ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method and_filter.
|
METHOD and_filter.
|
||||||
|
|
||||||
data li_json type ref to z2ui5_if_ajson.
|
DATA li_json TYPE REF TO z2ui5_if_ajson.
|
||||||
data li_json_filtered type ref to z2ui5_if_ajson.
|
DATA li_json_filtered TYPE REF TO z2ui5_if_ajson.
|
||||||
data lt_filters type z2ui5_if_ajson_filter=>ty_filter_tab.
|
DATA lt_filters TYPE z2ui5_if_ajson_filter=>ty_filter_tab.
|
||||||
|
|
||||||
append z2ui5_cl_ajson_filter_lib=>create_empty_filter( ) to lt_filters.
|
APPEND z2ui5_cl_ajson_filter_lib=>create_empty_filter( ) TO lt_filters.
|
||||||
append z2ui5_cl_ajson_filter_lib=>create_path_filter( iv_skip_paths = '/c' ) to lt_filters.
|
APPEND z2ui5_cl_ajson_filter_lib=>create_path_filter( iv_skip_paths = '/c' ) TO lt_filters.
|
||||||
|
|
||||||
li_json = z2ui5_cl_ajson=>create_empty( ).
|
li_json = z2ui5_cl_ajson=>create_empty( ).
|
||||||
li_json->set(
|
li_json->set(
|
||||||
|
@ -225,6 +225,6 @@ class ltcl_filters_test implementation.
|
||||||
act = li_json_filtered->stringify( )
|
act = li_json_filtered->stringify( )
|
||||||
exp = '{"a":"1"}' ).
|
exp = '{"a":"1"}' ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
|
@ -1,156 +1,156 @@
|
||||||
class z2ui5_cl_ajson_mapping definition
|
CLASS z2ui5_cl_ajson_mapping DEFINITION
|
||||||
public
|
PUBLIC
|
||||||
final
|
FINAL
|
||||||
create public.
|
CREATE PUBLIC.
|
||||||
|
|
||||||
public section.
|
PUBLIC SECTION.
|
||||||
|
|
||||||
constants:
|
CONSTANTS:
|
||||||
begin of rename_by,
|
BEGIN OF rename_by,
|
||||||
attr_name type i value 0,
|
attr_name TYPE i VALUE 0,
|
||||||
full_path type i value 1,
|
full_path TYPE i VALUE 1,
|
||||||
pattern type i value 2,
|
pattern TYPE i VALUE 2,
|
||||||
" regex type i value 3, " TODO add if needed in future
|
" regex type i value 3, " TODO add if needed in future
|
||||||
end of rename_by.
|
END OF rename_by.
|
||||||
|
|
||||||
class-methods create_camel_case " DEPRECATED
|
CLASS-METHODS create_camel_case " DEPRECATED
|
||||||
importing
|
IMPORTING
|
||||||
it_mapping_fields type z2ui5_if_ajson_mapping=>ty_mapping_fields optional
|
it_mapping_fields TYPE z2ui5_if_ajson_mapping=>ty_mapping_fields OPTIONAL
|
||||||
iv_first_json_upper type abap_bool default abap_true
|
iv_first_json_upper TYPE abap_bool DEFAULT abap_true
|
||||||
returning
|
RETURNING
|
||||||
value(ri_mapping) type ref to z2ui5_if_ajson_mapping.
|
VALUE(ri_mapping) TYPE REF TO z2ui5_if_ajson_mapping.
|
||||||
|
|
||||||
class-methods create_upper_case
|
CLASS-METHODS create_upper_case
|
||||||
importing
|
IMPORTING
|
||||||
it_mapping_fields type z2ui5_if_ajson_mapping=>ty_mapping_fields optional
|
it_mapping_fields TYPE z2ui5_if_ajson_mapping=>ty_mapping_fields OPTIONAL
|
||||||
returning
|
RETURNING
|
||||||
value(ri_mapping) type ref to z2ui5_if_ajson_mapping.
|
VALUE(ri_mapping) TYPE REF TO z2ui5_if_ajson_mapping.
|
||||||
|
|
||||||
class-methods create_lower_case
|
CLASS-METHODS create_lower_case
|
||||||
importing
|
IMPORTING
|
||||||
it_mapping_fields type z2ui5_if_ajson_mapping=>ty_mapping_fields optional
|
it_mapping_fields TYPE z2ui5_if_ajson_mapping=>ty_mapping_fields OPTIONAL
|
||||||
returning
|
RETURNING
|
||||||
value(ri_mapping) type ref to z2ui5_if_ajson_mapping.
|
VALUE(ri_mapping) TYPE REF TO z2ui5_if_ajson_mapping.
|
||||||
|
|
||||||
class-methods create_field_mapping " DEPRECATED
|
CLASS-METHODS create_field_mapping " DEPRECATED
|
||||||
importing
|
IMPORTING
|
||||||
it_mapping_fields type z2ui5_if_ajson_mapping=>ty_mapping_fields
|
it_mapping_fields TYPE z2ui5_if_ajson_mapping=>ty_mapping_fields
|
||||||
returning
|
RETURNING
|
||||||
value(ri_mapping) type ref to z2ui5_if_ajson_mapping.
|
VALUE(ri_mapping) TYPE REF TO z2ui5_if_ajson_mapping.
|
||||||
|
|
||||||
class-methods create_rename
|
CLASS-METHODS create_rename
|
||||||
importing
|
IMPORTING
|
||||||
it_rename_map type z2ui5_if_ajson_mapping=>tty_rename_map
|
it_rename_map TYPE z2ui5_if_ajson_mapping=>tty_rename_map
|
||||||
iv_rename_by type i default rename_by-attr_name
|
iv_rename_by TYPE i DEFAULT rename_by-attr_name
|
||||||
returning
|
RETURNING
|
||||||
value(ri_mapping) type ref to z2ui5_if_ajson_mapping.
|
VALUE(ri_mapping) TYPE REF TO z2ui5_if_ajson_mapping.
|
||||||
|
|
||||||
class-methods create_compound_mapper
|
CLASS-METHODS create_compound_mapper
|
||||||
importing
|
IMPORTING
|
||||||
ii_mapper1 type ref to z2ui5_if_ajson_mapping optional
|
ii_mapper1 TYPE REF TO z2ui5_if_ajson_mapping OPTIONAL
|
||||||
ii_mapper2 type ref to z2ui5_if_ajson_mapping optional
|
ii_mapper2 TYPE REF TO z2ui5_if_ajson_mapping OPTIONAL
|
||||||
ii_mapper3 type ref to z2ui5_if_ajson_mapping optional
|
ii_mapper3 TYPE REF TO z2ui5_if_ajson_mapping OPTIONAL
|
||||||
it_more type z2ui5_if_ajson_mapping=>ty_table_of optional
|
it_more TYPE z2ui5_if_ajson_mapping=>ty_table_of OPTIONAL
|
||||||
returning
|
RETURNING
|
||||||
value(ri_mapping) type ref to z2ui5_if_ajson_mapping.
|
VALUE(ri_mapping) TYPE REF TO z2ui5_if_ajson_mapping.
|
||||||
|
|
||||||
class-methods create_to_snake_case
|
CLASS-METHODS create_to_snake_case
|
||||||
returning
|
RETURNING
|
||||||
value(ri_mapping) type ref to z2ui5_if_ajson_mapping.
|
VALUE(ri_mapping) TYPE REF TO z2ui5_if_ajson_mapping.
|
||||||
|
|
||||||
class-methods create_to_camel_case
|
CLASS-METHODS create_to_camel_case
|
||||||
importing
|
IMPORTING
|
||||||
iv_first_json_upper type abap_bool default abap_false
|
iv_first_json_upper TYPE abap_bool DEFAULT abap_false
|
||||||
returning
|
RETURNING
|
||||||
value(ri_mapping) type ref to z2ui5_if_ajson_mapping.
|
VALUE(ri_mapping) TYPE REF TO z2ui5_if_ajson_mapping.
|
||||||
|
|
||||||
protected section.
|
PROTECTED SECTION.
|
||||||
|
|
||||||
private section.
|
PRIVATE SECTION.
|
||||||
|
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CLASS Z2UI5_CL_AJSON_MAPPING IMPLEMENTATION.
|
CLASS z2ui5_cl_ajson_mapping IMPLEMENTATION.
|
||||||
|
|
||||||
|
|
||||||
method create_camel_case.
|
METHOD create_camel_case.
|
||||||
|
|
||||||
create object ri_mapping type lcl_mapping_camel
|
CREATE OBJECT ri_mapping TYPE lcl_mapping_camel
|
||||||
exporting
|
EXPORTING
|
||||||
it_mapping_fields = it_mapping_fields
|
it_mapping_fields = it_mapping_fields
|
||||||
iv_first_json_upper = iv_first_json_upper.
|
iv_first_json_upper = iv_first_json_upper.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method create_compound_mapper.
|
METHOD create_compound_mapper.
|
||||||
|
|
||||||
data lt_queue type z2ui5_if_ajson_mapping=>ty_table_of.
|
DATA lt_queue TYPE z2ui5_if_ajson_mapping=>ty_table_of.
|
||||||
|
|
||||||
append ii_mapper1 to lt_queue.
|
APPEND ii_mapper1 TO lt_queue.
|
||||||
append ii_mapper2 to lt_queue.
|
APPEND ii_mapper2 TO lt_queue.
|
||||||
append ii_mapper3 to lt_queue.
|
APPEND ii_mapper3 TO lt_queue.
|
||||||
append lines of it_more to lt_queue.
|
APPEND LINES OF it_more TO lt_queue.
|
||||||
delete lt_queue where table_line is initial.
|
DELETE lt_queue WHERE table_line IS INITIAL.
|
||||||
|
|
||||||
create object ri_mapping type lcl_compound_mapper
|
CREATE OBJECT ri_mapping TYPE lcl_compound_mapper
|
||||||
exporting
|
EXPORTING
|
||||||
it_queue = lt_queue.
|
it_queue = lt_queue.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method create_field_mapping.
|
METHOD create_field_mapping.
|
||||||
|
|
||||||
create object ri_mapping type lcl_mapping_fields
|
CREATE OBJECT ri_mapping TYPE lcl_mapping_fields
|
||||||
exporting
|
EXPORTING
|
||||||
it_mapping_fields = it_mapping_fields.
|
it_mapping_fields = it_mapping_fields.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method create_lower_case.
|
METHOD create_lower_case.
|
||||||
|
|
||||||
create object ri_mapping type lcl_mapping_to_lower
|
CREATE OBJECT ri_mapping TYPE lcl_mapping_to_lower
|
||||||
exporting
|
EXPORTING
|
||||||
it_mapping_fields = it_mapping_fields.
|
it_mapping_fields = it_mapping_fields.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method create_rename.
|
METHOD create_rename.
|
||||||
|
|
||||||
create object ri_mapping type lcl_rename
|
CREATE OBJECT ri_mapping TYPE lcl_rename
|
||||||
exporting
|
EXPORTING
|
||||||
it_rename_map = it_rename_map
|
it_rename_map = it_rename_map
|
||||||
iv_rename_by = iv_rename_by.
|
iv_rename_by = iv_rename_by.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method create_to_camel_case.
|
METHOD create_to_camel_case.
|
||||||
|
|
||||||
create object ri_mapping type lcl_to_camel
|
CREATE OBJECT ri_mapping TYPE lcl_to_camel
|
||||||
exporting
|
EXPORTING
|
||||||
iv_first_json_upper = iv_first_json_upper.
|
iv_first_json_upper = iv_first_json_upper.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method create_to_snake_case.
|
METHOD create_to_snake_case.
|
||||||
|
|
||||||
create object ri_mapping type lcl_to_snake.
|
CREATE OBJECT ri_mapping TYPE lcl_to_snake.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method create_upper_case.
|
METHOD create_upper_case.
|
||||||
|
|
||||||
create object ri_mapping type lcl_mapping_to_upper
|
CREATE OBJECT ri_mapping TYPE lcl_mapping_to_upper
|
||||||
exporting
|
EXPORTING
|
||||||
it_mapping_fields = it_mapping_fields.
|
it_mapping_fields = it_mapping_fields.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
|
@ -1,116 +1,116 @@
|
||||||
class lcl_mapping_fields definition.
|
CLASS lcl_mapping_fields DEFINITION.
|
||||||
|
|
||||||
public section.
|
PUBLIC SECTION.
|
||||||
interfaces z2ui5_if_ajson_mapping.
|
INTERFACES z2ui5_if_ajson_mapping.
|
||||||
|
|
||||||
methods constructor
|
METHODS constructor
|
||||||
importing
|
IMPORTING
|
||||||
it_mapping_fields type z2ui5_if_ajson_mapping~ty_mapping_fields optional.
|
it_mapping_fields TYPE z2ui5_if_ajson_mapping~ty_mapping_fields OPTIONAL.
|
||||||
|
|
||||||
protected section.
|
PROTECTED SECTION.
|
||||||
|
|
||||||
private section.
|
PRIVATE SECTION.
|
||||||
data mt_mapping_fields type z2ui5_if_ajson_mapping~ty_mapping_fields.
|
DATA mt_mapping_fields TYPE z2ui5_if_ajson_mapping~ty_mapping_fields.
|
||||||
|
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
||||||
class lcl_rename definition.
|
CLASS lcl_rename DEFINITION.
|
||||||
|
|
||||||
public section.
|
PUBLIC SECTION.
|
||||||
interfaces z2ui5_if_ajson_mapping.
|
INTERFACES z2ui5_if_ajson_mapping.
|
||||||
|
|
||||||
methods constructor
|
METHODS constructor
|
||||||
importing
|
IMPORTING
|
||||||
it_rename_map type z2ui5_if_ajson_mapping~tty_rename_map
|
it_rename_map TYPE z2ui5_if_ajson_mapping~tty_rename_map
|
||||||
iv_rename_by type i.
|
iv_rename_by TYPE i.
|
||||||
|
|
||||||
protected section.
|
PROTECTED SECTION.
|
||||||
|
|
||||||
private section.
|
PRIVATE SECTION.
|
||||||
data mt_rename_map type z2ui5_if_ajson_mapping~tty_rename_map.
|
DATA mt_rename_map TYPE z2ui5_if_ajson_mapping~tty_rename_map.
|
||||||
data mv_rename_by type i.
|
DATA mv_rename_by TYPE i.
|
||||||
|
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
||||||
class lcl_mapping_to_upper definition.
|
CLASS lcl_mapping_to_upper DEFINITION.
|
||||||
|
|
||||||
public section.
|
PUBLIC SECTION.
|
||||||
interfaces z2ui5_if_ajson_mapping.
|
INTERFACES z2ui5_if_ajson_mapping.
|
||||||
|
|
||||||
methods constructor
|
METHODS constructor
|
||||||
importing
|
IMPORTING
|
||||||
it_mapping_fields type z2ui5_if_ajson_mapping~ty_mapping_fields optional.
|
it_mapping_fields TYPE z2ui5_if_ajson_mapping~ty_mapping_fields OPTIONAL.
|
||||||
|
|
||||||
protected section.
|
PROTECTED SECTION.
|
||||||
|
|
||||||
private section.
|
PRIVATE SECTION.
|
||||||
data mi_mapping_fields type ref to z2ui5_if_ajson_mapping.
|
DATA mi_mapping_fields TYPE REF TO z2ui5_if_ajson_mapping.
|
||||||
|
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
class lcl_mapping_to_lower definition.
|
CLASS lcl_mapping_to_lower DEFINITION.
|
||||||
|
|
||||||
public section.
|
PUBLIC SECTION.
|
||||||
interfaces z2ui5_if_ajson_mapping.
|
INTERFACES z2ui5_if_ajson_mapping.
|
||||||
|
|
||||||
methods constructor
|
METHODS constructor
|
||||||
importing
|
IMPORTING
|
||||||
it_mapping_fields type z2ui5_if_ajson_mapping~ty_mapping_fields optional.
|
it_mapping_fields TYPE z2ui5_if_ajson_mapping~ty_mapping_fields OPTIONAL.
|
||||||
|
|
||||||
protected section.
|
PROTECTED SECTION.
|
||||||
|
|
||||||
private section.
|
PRIVATE SECTION.
|
||||||
data mi_mapping_fields type ref to z2ui5_if_ajson_mapping.
|
DATA mi_mapping_fields TYPE REF TO z2ui5_if_ajson_mapping.
|
||||||
|
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
class lcl_mapping_camel definition.
|
CLASS lcl_mapping_camel DEFINITION.
|
||||||
|
|
||||||
public section.
|
PUBLIC SECTION.
|
||||||
interfaces z2ui5_if_ajson_mapping.
|
INTERFACES z2ui5_if_ajson_mapping.
|
||||||
|
|
||||||
methods constructor
|
METHODS constructor
|
||||||
importing
|
IMPORTING
|
||||||
it_mapping_fields type z2ui5_if_ajson_mapping~ty_mapping_fields optional
|
it_mapping_fields TYPE z2ui5_if_ajson_mapping~ty_mapping_fields OPTIONAL
|
||||||
iv_first_json_upper type abap_bool default abap_true.
|
iv_first_json_upper TYPE abap_bool DEFAULT abap_true.
|
||||||
|
|
||||||
protected section.
|
PROTECTED SECTION.
|
||||||
|
|
||||||
private section.
|
PRIVATE SECTION.
|
||||||
data mv_first_json_upper type abap_bool.
|
DATA mv_first_json_upper TYPE abap_bool.
|
||||||
data mi_mapping_fields type ref to z2ui5_if_ajson_mapping.
|
DATA mi_mapping_fields TYPE REF TO z2ui5_if_ajson_mapping.
|
||||||
|
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
||||||
class lcl_compound_mapper definition.
|
CLASS lcl_compound_mapper DEFINITION.
|
||||||
|
|
||||||
public section.
|
PUBLIC SECTION.
|
||||||
interfaces z2ui5_if_ajson_mapping.
|
INTERFACES z2ui5_if_ajson_mapping.
|
||||||
|
|
||||||
methods constructor
|
METHODS constructor
|
||||||
importing
|
IMPORTING
|
||||||
it_queue type z2ui5_if_ajson_mapping=>ty_table_of.
|
it_queue TYPE z2ui5_if_ajson_mapping=>ty_table_of.
|
||||||
|
|
||||||
protected section.
|
PROTECTED SECTION.
|
||||||
|
|
||||||
private section.
|
PRIVATE SECTION.
|
||||||
data mt_queue type z2ui5_if_ajson_mapping=>ty_table_of.
|
DATA mt_queue TYPE z2ui5_if_ajson_mapping=>ty_table_of.
|
||||||
|
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
||||||
class lcl_to_snake definition.
|
CLASS lcl_to_snake DEFINITION.
|
||||||
public section.
|
PUBLIC SECTION.
|
||||||
interfaces z2ui5_if_ajson_mapping.
|
INTERFACES z2ui5_if_ajson_mapping.
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
||||||
class lcl_to_camel definition.
|
CLASS lcl_to_camel DEFINITION.
|
||||||
public section.
|
PUBLIC SECTION.
|
||||||
interfaces z2ui5_if_ajson_mapping.
|
INTERFACES z2ui5_if_ajson_mapping.
|
||||||
methods constructor
|
METHODS constructor
|
||||||
importing
|
IMPORTING
|
||||||
iv_first_json_upper type abap_bool.
|
iv_first_json_upper TYPE abap_bool.
|
||||||
private section.
|
PRIVATE SECTION.
|
||||||
data mv_first_json_upper type abap_bool.
|
DATA mv_first_json_upper TYPE abap_bool.
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
|
@ -1,335 +1,341 @@
|
||||||
class lcl_mapping_fields implementation. "DEPRECATED
|
CLASS lcl_mapping_fields IMPLEMENTATION. "DEPRECATED
|
||||||
|
|
||||||
|
|
||||||
method constructor.
|
METHOD constructor.
|
||||||
|
|
||||||
data ls_mapping_field like line of mt_mapping_fields.
|
DATA ls_mapping_field LIKE LINE OF mt_mapping_fields.
|
||||||
|
|
||||||
loop at it_mapping_fields into ls_mapping_field.
|
LOOP AT it_mapping_fields INTO ls_mapping_field.
|
||||||
ls_mapping_field-abap = to_upper( ls_mapping_field-abap ).
|
ls_mapping_field-abap = to_upper( ls_mapping_field-abap ).
|
||||||
insert ls_mapping_field into table mt_mapping_fields.
|
INSERT ls_mapping_field INTO TABLE mt_mapping_fields.
|
||||||
endloop.
|
ENDLOOP.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method z2ui5_if_ajson_mapping~to_abap.
|
METHOD z2ui5_if_ajson_mapping~to_abap.
|
||||||
|
|
||||||
data ls_mapping_field like line of mt_mapping_fields.
|
DATA ls_mapping_field LIKE LINE OF mt_mapping_fields.
|
||||||
|
|
||||||
read table mt_mapping_fields into ls_mapping_field
|
READ TABLE mt_mapping_fields INTO ls_mapping_field
|
||||||
with key json components json = iv_name.
|
WITH KEY json COMPONENTS json = iv_name.
|
||||||
if sy-subrc = 0.
|
IF sy-subrc = 0.
|
||||||
rv_result = ls_mapping_field-abap.
|
rv_result = ls_mapping_field-abap.
|
||||||
endif.
|
ENDIF.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method z2ui5_if_ajson_mapping~to_json.
|
METHOD z2ui5_if_ajson_mapping~to_json.
|
||||||
|
|
||||||
data lv_field type string.
|
DATA lv_field TYPE string.
|
||||||
data ls_mapping_field like line of mt_mapping_fields.
|
DATA ls_mapping_field LIKE LINE OF mt_mapping_fields.
|
||||||
|
|
||||||
lv_field = to_upper( iv_name ).
|
lv_field = to_upper( iv_name ).
|
||||||
|
|
||||||
read table mt_mapping_fields into ls_mapping_field
|
READ TABLE mt_mapping_fields INTO ls_mapping_field
|
||||||
with key abap components abap = lv_field.
|
WITH KEY abap COMPONENTS abap = lv_field.
|
||||||
if sy-subrc = 0.
|
IF sy-subrc = 0.
|
||||||
rv_result = ls_mapping_field-json.
|
rv_result = ls_mapping_field-json.
|
||||||
endif.
|
ENDIF.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method z2ui5_if_ajson_mapping~rename_node.
|
METHOD z2ui5_if_ajson_mapping~rename_node.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
||||||
class lcl_rename implementation.
|
CLASS lcl_rename IMPLEMENTATION.
|
||||||
|
|
||||||
method constructor.
|
METHOD constructor.
|
||||||
mt_rename_map = it_rename_map.
|
mt_rename_map = it_rename_map.
|
||||||
mv_rename_by = iv_rename_by.
|
mv_rename_by = iv_rename_by.
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method z2ui5_if_ajson_mapping~to_abap.
|
METHOD z2ui5_if_ajson_mapping~to_abap.
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method z2ui5_if_ajson_mapping~to_json.
|
METHOD z2ui5_if_ajson_mapping~to_json.
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method z2ui5_if_ajson_mapping~rename_node.
|
METHOD z2ui5_if_ajson_mapping~rename_node.
|
||||||
|
|
||||||
data lv_full_path type string.
|
DATA lv_full_path TYPE string.
|
||||||
data lv_pair_found type abap_bool.
|
DATA lv_pair_found TYPE abap_bool.
|
||||||
field-symbols <r> like line of mt_rename_map.
|
FIELD-SYMBOLS <r> LIKE LINE OF mt_rename_map.
|
||||||
|
|
||||||
case mv_rename_by.
|
CASE mv_rename_by.
|
||||||
when z2ui5_cl_ajson_mapping=>rename_by-attr_name.
|
WHEN z2ui5_cl_ajson_mapping=>rename_by-attr_name.
|
||||||
read table mt_rename_map assigning <r> with table key by_name components from = cv_name.
|
READ TABLE mt_rename_map ASSIGNING <r> WITH TABLE KEY by_name COMPONENTS from = cv_name.
|
||||||
lv_pair_found = boolc( sy-subrc = 0 ).
|
lv_pair_found = boolc( sy-subrc = 0 ).
|
||||||
when z2ui5_cl_ajson_mapping=>rename_by-full_path.
|
WHEN z2ui5_cl_ajson_mapping=>rename_by-full_path.
|
||||||
lv_full_path = is_node-path && cv_name.
|
lv_full_path = is_node-path && cv_name.
|
||||||
read table mt_rename_map assigning <r> with table key by_name components from = lv_full_path.
|
READ TABLE mt_rename_map ASSIGNING <r> WITH TABLE KEY by_name COMPONENTS from = lv_full_path.
|
||||||
lv_pair_found = boolc( sy-subrc = 0 ).
|
lv_pair_found = boolc( sy-subrc = 0 ).
|
||||||
when z2ui5_cl_ajson_mapping=>rename_by-pattern.
|
WHEN z2ui5_cl_ajson_mapping=>rename_by-pattern.
|
||||||
lv_full_path = is_node-path && cv_name.
|
lv_full_path = is_node-path && cv_name.
|
||||||
loop at mt_rename_map assigning <r>.
|
LOOP AT mt_rename_map ASSIGNING <r>.
|
||||||
if lv_full_path cp <r>-from.
|
IF lv_full_path CP <r>-from.
|
||||||
lv_pair_found = abap_true.
|
lv_pair_found = abap_true.
|
||||||
exit.
|
EXIT.
|
||||||
endif.
|
ENDIF.
|
||||||
endloop.
|
ENDLOOP.
|
||||||
when others.
|
WHEN OTHERS.
|
||||||
lv_pair_found = abap_false. " No rename
|
lv_pair_found = abap_false. " No rename
|
||||||
endcase.
|
ENDCASE.
|
||||||
|
|
||||||
if lv_pair_found = abap_true.
|
IF lv_pair_found = abap_true.
|
||||||
cv_name = <r>-to.
|
cv_name = <r>-to.
|
||||||
endif.
|
ENDIF.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
||||||
class lcl_mapping_to_upper implementation.
|
CLASS lcl_mapping_to_upper IMPLEMENTATION.
|
||||||
|
|
||||||
|
|
||||||
method constructor.
|
METHOD constructor.
|
||||||
|
|
||||||
mi_mapping_fields = z2ui5_cl_ajson_mapping=>create_field_mapping( it_mapping_fields ).
|
mi_mapping_fields = z2ui5_cl_ajson_mapping=>create_field_mapping( it_mapping_fields ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method z2ui5_if_ajson_mapping~to_abap.
|
METHOD z2ui5_if_ajson_mapping~to_abap.
|
||||||
|
|
||||||
rv_result = mi_mapping_fields->to_abap( iv_path = iv_path iv_name = iv_name ).
|
rv_result = mi_mapping_fields->to_abap( iv_path = iv_path
|
||||||
|
iv_name = iv_name ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method z2ui5_if_ajson_mapping~to_json.
|
METHOD z2ui5_if_ajson_mapping~to_json.
|
||||||
|
|
||||||
rv_result = mi_mapping_fields->to_json( iv_path = iv_path iv_name = iv_name ).
|
rv_result = mi_mapping_fields->to_json( iv_path = iv_path
|
||||||
|
iv_name = iv_name ).
|
||||||
|
|
||||||
if rv_result is not initial. " Mapping found
|
IF rv_result IS NOT INITIAL. " Mapping found
|
||||||
return.
|
RETURN.
|
||||||
endif.
|
ENDIF.
|
||||||
|
|
||||||
rv_result = to_upper( iv_name ).
|
rv_result = to_upper( iv_name ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method z2ui5_if_ajson_mapping~rename_node.
|
METHOD z2ui5_if_ajson_mapping~rename_node.
|
||||||
|
|
||||||
cv_name = to_upper( cv_name ).
|
cv_name = to_upper( cv_name ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
class lcl_mapping_to_lower implementation.
|
CLASS lcl_mapping_to_lower IMPLEMENTATION.
|
||||||
|
|
||||||
|
|
||||||
method constructor.
|
METHOD constructor.
|
||||||
|
|
||||||
mi_mapping_fields = z2ui5_cl_ajson_mapping=>create_field_mapping( it_mapping_fields ).
|
mi_mapping_fields = z2ui5_cl_ajson_mapping=>create_field_mapping( it_mapping_fields ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method z2ui5_if_ajson_mapping~to_abap.
|
METHOD z2ui5_if_ajson_mapping~to_abap.
|
||||||
|
|
||||||
rv_result = mi_mapping_fields->to_abap( iv_path = iv_path iv_name = iv_name ).
|
rv_result = mi_mapping_fields->to_abap( iv_path = iv_path
|
||||||
|
iv_name = iv_name ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method z2ui5_if_ajson_mapping~to_json.
|
METHOD z2ui5_if_ajson_mapping~to_json.
|
||||||
|
|
||||||
rv_result = mi_mapping_fields->to_json( iv_path = iv_path iv_name = iv_name ).
|
rv_result = mi_mapping_fields->to_json( iv_path = iv_path
|
||||||
|
iv_name = iv_name ).
|
||||||
|
|
||||||
if rv_result is not initial. " Mapping found
|
IF rv_result IS NOT INITIAL. " Mapping found
|
||||||
return.
|
RETURN.
|
||||||
endif.
|
ENDIF.
|
||||||
|
|
||||||
rv_result = to_lower( iv_name ).
|
rv_result = to_lower( iv_name ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method z2ui5_if_ajson_mapping~rename_node.
|
METHOD z2ui5_if_ajson_mapping~rename_node.
|
||||||
|
|
||||||
cv_name = to_lower( cv_name ).
|
cv_name = to_lower( cv_name ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
class lcl_mapping_camel implementation. "DEPRECATED
|
CLASS lcl_mapping_camel IMPLEMENTATION. "DEPRECATED
|
||||||
|
|
||||||
|
|
||||||
method constructor.
|
METHOD constructor.
|
||||||
|
|
||||||
mi_mapping_fields = z2ui5_cl_ajson_mapping=>create_field_mapping( it_mapping_fields ).
|
mi_mapping_fields = z2ui5_cl_ajson_mapping=>create_field_mapping( it_mapping_fields ).
|
||||||
mv_first_json_upper = iv_first_json_upper.
|
mv_first_json_upper = iv_first_json_upper.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method z2ui5_if_ajson_mapping~to_abap.
|
METHOD z2ui5_if_ajson_mapping~to_abap.
|
||||||
|
|
||||||
rv_result = mi_mapping_fields->to_abap( iv_path = iv_path iv_name = iv_name ).
|
rv_result = mi_mapping_fields->to_abap( iv_path = iv_path
|
||||||
|
iv_name = iv_name ).
|
||||||
|
|
||||||
if rv_result is not initial. " Mapping found
|
IF rv_result IS NOT INITIAL. " Mapping found
|
||||||
return.
|
RETURN.
|
||||||
endif.
|
ENDIF.
|
||||||
|
|
||||||
rv_result = iv_name.
|
rv_result = iv_name.
|
||||||
|
|
||||||
replace all occurrences of regex `([a-z])([A-Z])` in rv_result with `$1_$2`. "#EC NOTEXT
|
REPLACE ALL OCCURRENCES OF REGEX `([a-z])([A-Z])` IN rv_result WITH `$1_$2`.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method z2ui5_if_ajson_mapping~to_json.
|
METHOD z2ui5_if_ajson_mapping~to_json.
|
||||||
|
|
||||||
types ty_token type c length 255.
|
TYPES ty_token TYPE c LENGTH 255.
|
||||||
data lt_tokens TYPE STANDARD TABLE OF ty_token.
|
DATA lt_tokens TYPE STANDARD TABLE OF ty_token.
|
||||||
data lv_from type i.
|
DATA lv_from TYPE i.
|
||||||
field-symbols <token> like line of lt_tokens.
|
FIELD-SYMBOLS <token> LIKE LINE OF lt_tokens.
|
||||||
|
|
||||||
rv_result = mi_mapping_fields->to_json( iv_path = iv_path iv_name = iv_name ).
|
rv_result = mi_mapping_fields->to_json( iv_path = iv_path
|
||||||
|
iv_name = iv_name ).
|
||||||
|
|
||||||
if rv_result is not initial. " Mapping found
|
IF rv_result IS NOT INITIAL. " Mapping found
|
||||||
return.
|
RETURN.
|
||||||
endif.
|
ENDIF.
|
||||||
|
|
||||||
rv_result = iv_name.
|
rv_result = iv_name.
|
||||||
|
|
||||||
replace all occurrences of `__` in rv_result with `*`.
|
REPLACE ALL OCCURRENCES OF `__` IN rv_result WITH `*`.
|
||||||
|
|
||||||
translate rv_result to lower case.
|
TRANSLATE rv_result TO LOWER CASE.
|
||||||
translate rv_result using `/_:_~_`.
|
TRANSLATE rv_result USING `/_:_~_`.
|
||||||
|
|
||||||
if mv_first_json_upper = abap_true.
|
IF mv_first_json_upper = abap_true.
|
||||||
lv_from = 1.
|
lv_from = 1.
|
||||||
else.
|
ELSE.
|
||||||
lv_from = 2.
|
lv_from = 2.
|
||||||
endif.
|
ENDIF.
|
||||||
|
|
||||||
split rv_result at `_` into table lt_tokens.
|
SPLIT rv_result AT `_` INTO TABLE lt_tokens.
|
||||||
loop at lt_tokens assigning <token> from lv_from.
|
LOOP AT lt_tokens ASSIGNING <token> FROM lv_from.
|
||||||
translate <token>(1) to upper case.
|
TRANSLATE <token>(1) TO UPPER CASE.
|
||||||
endloop.
|
ENDLOOP.
|
||||||
|
|
||||||
concatenate lines of lt_tokens into rv_result.
|
CONCATENATE LINES OF lt_tokens INTO rv_result.
|
||||||
replace all occurrences of `*` in rv_result with `_`.
|
REPLACE ALL OCCURRENCES OF `*` IN rv_result WITH `_`.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method z2ui5_if_ajson_mapping~rename_node.
|
METHOD z2ui5_if_ajson_mapping~rename_node.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
||||||
class lcl_compound_mapper implementation.
|
CLASS lcl_compound_mapper IMPLEMENTATION.
|
||||||
|
|
||||||
method constructor.
|
METHOD constructor.
|
||||||
mt_queue = it_queue.
|
mt_queue = it_queue.
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method z2ui5_if_ajson_mapping~rename_node.
|
METHOD z2ui5_if_ajson_mapping~rename_node.
|
||||||
|
|
||||||
data ls_node like is_node.
|
DATA ls_node LIKE is_node.
|
||||||
data li_mapper like line of mt_queue.
|
DATA li_mapper LIKE LINE OF mt_queue.
|
||||||
|
|
||||||
ls_node = is_node.
|
ls_node = is_node.
|
||||||
|
|
||||||
loop at mt_queue into li_mapper.
|
LOOP AT mt_queue INTO li_mapper.
|
||||||
li_mapper->rename_node(
|
li_mapper->rename_node(
|
||||||
exporting
|
EXPORTING
|
||||||
is_node = ls_node
|
is_node = ls_node
|
||||||
changing
|
CHANGING
|
||||||
cv_name = cv_name ).
|
cv_name = cv_name ).
|
||||||
ls_node-name = cv_name.
|
ls_node-name = cv_name.
|
||||||
endloop.
|
ENDLOOP.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method z2ui5_if_ajson_mapping~to_abap.
|
METHOD z2ui5_if_ajson_mapping~to_abap.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method z2ui5_if_ajson_mapping~to_json.
|
METHOD z2ui5_if_ajson_mapping~to_json.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
||||||
class lcl_to_snake implementation.
|
CLASS lcl_to_snake IMPLEMENTATION.
|
||||||
|
|
||||||
method z2ui5_if_ajson_mapping~rename_node.
|
METHOD z2ui5_if_ajson_mapping~rename_node.
|
||||||
|
|
||||||
replace all occurrences of regex `([a-z])([A-Z])` in cv_name with `$1_$2`. "#EC NOTEXT
|
REPLACE ALL OCCURRENCES OF REGEX `([a-z])([A-Z])` IN cv_name WITH `$1_$2`.
|
||||||
cv_name = to_lower( cv_name ).
|
cv_name = to_lower( cv_name ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method z2ui5_if_ajson_mapping~to_abap.
|
METHOD z2ui5_if_ajson_mapping~to_abap.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method z2ui5_if_ajson_mapping~to_json.
|
METHOD z2ui5_if_ajson_mapping~to_json.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
||||||
class lcl_to_camel implementation.
|
CLASS lcl_to_camel IMPLEMENTATION.
|
||||||
|
|
||||||
method constructor.
|
METHOD constructor.
|
||||||
mv_first_json_upper = iv_first_json_upper.
|
mv_first_json_upper = iv_first_json_upper.
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method z2ui5_if_ajson_mapping~rename_node.
|
METHOD z2ui5_if_ajson_mapping~rename_node.
|
||||||
|
|
||||||
types lty_token type c length 255.
|
TYPES lty_token TYPE c LENGTH 255.
|
||||||
constants lc_forced_underscore_marker type c length 1 value cl_abap_char_utilities=>horizontal_tab.
|
CONSTANTS lc_forced_underscore_marker TYPE c LENGTH 1 VALUE cl_abap_char_utilities=>horizontal_tab.
|
||||||
|
|
||||||
data lt_tokens TYPE STANDARD TABLE OF lty_token.
|
DATA lt_tokens TYPE STANDARD TABLE OF lty_token.
|
||||||
data lv_from type i.
|
DATA lv_from TYPE i.
|
||||||
field-symbols <token> like line of lt_tokens.
|
FIELD-SYMBOLS <token> LIKE LINE OF lt_tokens.
|
||||||
|
|
||||||
if mv_first_json_upper = abap_true.
|
IF mv_first_json_upper = abap_true.
|
||||||
lv_from = 1.
|
lv_from = 1.
|
||||||
else.
|
ELSE.
|
||||||
lv_from = 2.
|
lv_from = 2.
|
||||||
endif.
|
ENDIF.
|
||||||
replace all occurrences of `__` in cv_name with lc_forced_underscore_marker. " Force underscore
|
REPLACE ALL OCCURRENCES OF `__` IN cv_name WITH lc_forced_underscore_marker. " Force underscore
|
||||||
|
|
||||||
split cv_name at `_` into table lt_tokens.
|
SPLIT cv_name AT `_` INTO TABLE lt_tokens.
|
||||||
delete lt_tokens where table_line is initial.
|
DELETE lt_tokens WHERE table_line IS INITIAL.
|
||||||
loop at lt_tokens assigning <token> from lv_from.
|
LOOP AT lt_tokens ASSIGNING <token> FROM lv_from.
|
||||||
translate <token>+0(1) to upper case.
|
TRANSLATE <token>+0(1) TO UPPER CASE.
|
||||||
endloop.
|
ENDLOOP.
|
||||||
|
|
||||||
concatenate lines of lt_tokens into cv_name.
|
CONCATENATE LINES OF lt_tokens INTO cv_name.
|
||||||
replace all occurrences of lc_forced_underscore_marker in cv_name with `_`.
|
REPLACE ALL OCCURRENCES OF lc_forced_underscore_marker IN cv_name WITH `_`.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method z2ui5_if_ajson_mapping~to_abap.
|
METHOD z2ui5_if_ajson_mapping~to_abap.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method z2ui5_if_ajson_mapping~to_json.
|
METHOD z2ui5_if_ajson_mapping~to_json.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
|
@ -1,84 +1,86 @@
|
||||||
class ltcl_test_mappers definition final for testing
|
CLASS ltcl_test_mappers DEFINITION FINAL FOR TESTING
|
||||||
duration short
|
DURATION SHORT
|
||||||
risk level harmless.
|
RISK LEVEL HARMLESS.
|
||||||
|
|
||||||
private section.
|
PRIVATE SECTION.
|
||||||
methods:
|
METHODS:
|
||||||
from_json_to_json for testing raising z2UI5_cx_ajson_error,
|
from_json_to_json FOR TESTING RAISING z2ui5_cx_ajson_error,
|
||||||
to_abap for testing raising z2UI5_cx_ajson_error,
|
to_abap FOR TESTING RAISING z2ui5_cx_ajson_error,
|
||||||
to_json for testing raising z2UI5_cx_ajson_error,
|
to_json FOR TESTING RAISING z2ui5_cx_ajson_error,
|
||||||
to_json_nested_struc for testing raising z2UI5_cx_ajson_error,
|
to_json_nested_struc FOR TESTING RAISING z2ui5_cx_ajson_error,
|
||||||
to_json_nested_table for testing raising z2UI5_cx_ajson_error,
|
to_json_nested_table FOR TESTING RAISING z2ui5_cx_ajson_error,
|
||||||
to_json_first_lower for testing raising z2UI5_cx_ajson_error.
|
to_json_first_lower FOR TESTING RAISING z2ui5_cx_ajson_error.
|
||||||
|
|
||||||
methods:
|
METHODS:
|
||||||
to_snake for testing raising z2UI5_cx_ajson_error,
|
to_snake FOR TESTING RAISING z2ui5_cx_ajson_error,
|
||||||
to_camel for testing raising z2UI5_cx_ajson_error,
|
to_camel FOR TESTING RAISING z2ui5_cx_ajson_error,
|
||||||
to_camel_1st_upper for testing raising z2UI5_cx_ajson_error,
|
to_camel_1st_upper FOR TESTING RAISING z2ui5_cx_ajson_error,
|
||||||
rename_by_attr for testing raising z2UI5_cx_ajson_error,
|
rename_by_attr FOR TESTING RAISING z2ui5_cx_ajson_error,
|
||||||
rename_by_path for testing raising z2UI5_cx_ajson_error,
|
rename_by_path FOR TESTING RAISING z2ui5_cx_ajson_error,
|
||||||
rename_by_pattern for testing raising z2UI5_cx_ajson_error,
|
rename_by_pattern FOR TESTING RAISING z2ui5_cx_ajson_error,
|
||||||
compound_mapper for testing raising z2UI5_cx_ajson_error,
|
compound_mapper FOR TESTING RAISING z2ui5_cx_ajson_error,
|
||||||
test_to_upper for testing raising z2UI5_cx_ajson_error,
|
test_to_upper FOR TESTING RAISING z2ui5_cx_ajson_error,
|
||||||
test_to_lower for testing raising z2UI5_cx_ajson_error.
|
test_to_lower FOR TESTING RAISING z2ui5_cx_ajson_error.
|
||||||
|
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
class ltcl_test_mappers implementation.
|
CLASS ltcl_test_mappers IMPLEMENTATION.
|
||||||
|
|
||||||
|
|
||||||
method from_json_to_json.
|
METHOD from_json_to_json.
|
||||||
|
|
||||||
data:
|
DATA:
|
||||||
lo_ajson type ref to z2ui5_cl_ajson.
|
lo_ajson TYPE REF TO z2ui5_cl_ajson.
|
||||||
|
|
||||||
lo_ajson =
|
lo_ajson =
|
||||||
z2ui5_cl_ajson=>parse(
|
z2ui5_cl_ajson=>parse(
|
||||||
iv_json = `{"fieldData":"field_value"}`
|
iv_json = `{"fieldData":"field_value"}`
|
||||||
ii_custom_mapping = z2ui5_cl_ajson_mapping=>create_camel_case( iv_first_json_upper = abap_false ) ).
|
ii_custom_mapping = z2ui5_cl_ajson_mapping=>create_camel_case( iv_first_json_upper = abap_false ) ).
|
||||||
|
|
||||||
lo_ajson->set_string( iv_path = `/fieldData` iv_val = 'E' ).
|
lo_ajson->set_string( iv_path = `/fieldData`
|
||||||
|
iv_val = 'E' ).
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = lo_ajson->stringify( )
|
act = lo_ajson->stringify( )
|
||||||
exp = '{"fieldData":"E"}' ).
|
exp = '{"fieldData":"E"}' ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method to_abap.
|
METHOD to_abap.
|
||||||
|
|
||||||
data:
|
DATA:
|
||||||
lo_ajson type ref to z2ui5_cl_ajson,
|
lo_ajson TYPE REF TO z2ui5_cl_ajson,
|
||||||
li_mapping type ref to z2ui5_if_ajson_mapping.
|
li_mapping TYPE REF TO z2ui5_if_ajson_mapping.
|
||||||
data:
|
DATA:
|
||||||
begin of ls_result,
|
BEGIN OF ls_result,
|
||||||
field_data type string,
|
field_data TYPE string,
|
||||||
end of ls_result.
|
END OF ls_result.
|
||||||
|
|
||||||
li_mapping = z2ui5_cl_ajson_mapping=>create_camel_case( ).
|
li_mapping = z2ui5_cl_ajson_mapping=>create_camel_case( ).
|
||||||
|
|
||||||
lo_ajson = z2ui5_cl_ajson=>parse( iv_json = '{"FieldData":"field_value"}' ii_custom_mapping = li_mapping ).
|
lo_ajson = z2ui5_cl_ajson=>parse( iv_json = '{"FieldData":"field_value"}'
|
||||||
|
ii_custom_mapping = li_mapping ).
|
||||||
|
|
||||||
lo_ajson->to_abap( importing ev_container = ls_result ).
|
lo_ajson->to_abap( IMPORTING ev_container = ls_result ).
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = ls_result-field_data
|
act = ls_result-field_data
|
||||||
exp = 'field_value' ).
|
exp = 'field_value' ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method to_json.
|
METHOD to_json.
|
||||||
|
|
||||||
data:
|
DATA:
|
||||||
lo_ajson type ref to z2ui5_cl_ajson,
|
lo_ajson TYPE REF TO z2ui5_cl_ajson,
|
||||||
li_mapping type ref to z2ui5_if_ajson_mapping.
|
li_mapping TYPE REF TO z2ui5_if_ajson_mapping.
|
||||||
data:
|
DATA:
|
||||||
begin of ls_result,
|
BEGIN OF ls_result,
|
||||||
field_data type string,
|
field_data TYPE string,
|
||||||
end of ls_result.
|
END OF ls_result.
|
||||||
|
|
||||||
li_mapping = z2ui5_cl_ajson_mapping=>create_camel_case( iv_first_json_upper = abap_false ).
|
li_mapping = z2ui5_cl_ajson_mapping=>create_camel_case( iv_first_json_upper = abap_false ).
|
||||||
|
|
||||||
|
@ -86,27 +88,28 @@ class ltcl_test_mappers implementation.
|
||||||
|
|
||||||
lo_ajson = z2ui5_cl_ajson=>create_empty( ii_custom_mapping = li_mapping ).
|
lo_ajson = z2ui5_cl_ajson=>create_empty( ii_custom_mapping = li_mapping ).
|
||||||
|
|
||||||
lo_ajson->set( iv_path = '/' iv_val = ls_result ).
|
lo_ajson->set( iv_path = '/'
|
||||||
|
iv_val = ls_result ).
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = lo_ajson->stringify( )
|
act = lo_ajson->stringify( )
|
||||||
exp = '{"fieldData":"field_value"}' ).
|
exp = '{"fieldData":"field_value"}' ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method to_json_nested_struc.
|
METHOD to_json_nested_struc.
|
||||||
|
|
||||||
data:
|
DATA:
|
||||||
lo_ajson type ref to z2ui5_cl_ajson,
|
lo_ajson TYPE REF TO z2ui5_cl_ajson,
|
||||||
li_mapping type ref to z2ui5_if_ajson_mapping.
|
li_mapping TYPE REF TO z2ui5_if_ajson_mapping.
|
||||||
data:
|
DATA:
|
||||||
begin of ls_result,
|
BEGIN OF ls_result,
|
||||||
field_data type string,
|
field_data TYPE string,
|
||||||
begin of struc_data,
|
BEGIN OF struc_data,
|
||||||
field_more type string,
|
field_more TYPE string,
|
||||||
end of struc_data,
|
END OF struc_data,
|
||||||
end of ls_result.
|
END OF ls_result.
|
||||||
|
|
||||||
li_mapping = z2ui5_cl_ajson_mapping=>create_camel_case( iv_first_json_upper = abap_false ).
|
li_mapping = z2ui5_cl_ajson_mapping=>create_camel_case( iv_first_json_upper = abap_false ).
|
||||||
|
|
||||||
|
@ -115,34 +118,35 @@ class ltcl_test_mappers implementation.
|
||||||
|
|
||||||
lo_ajson = z2ui5_cl_ajson=>create_empty( ii_custom_mapping = li_mapping ).
|
lo_ajson = z2ui5_cl_ajson=>create_empty( ii_custom_mapping = li_mapping ).
|
||||||
|
|
||||||
lo_ajson->set( iv_path = '/' iv_val = ls_result ).
|
lo_ajson->set( iv_path = '/'
|
||||||
|
iv_val = ls_result ).
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = lo_ajson->stringify( )
|
act = lo_ajson->stringify( )
|
||||||
exp = '{"fieldData":"field_value","strucData":{"fieldMore":"field_more"}}' ).
|
exp = '{"fieldData":"field_value","strucData":{"fieldMore":"field_more"}}' ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method to_json_nested_table.
|
METHOD to_json_nested_table.
|
||||||
|
|
||||||
data:
|
DATA:
|
||||||
lo_ajson type ref to z2ui5_cl_ajson,
|
lo_ajson TYPE REF TO z2ui5_cl_ajson,
|
||||||
li_mapping type ref to z2ui5_if_ajson_mapping.
|
li_mapping TYPE REF TO z2ui5_if_ajson_mapping.
|
||||||
data:
|
DATA:
|
||||||
lv_value type string,
|
lv_value TYPE string,
|
||||||
begin of ls_result,
|
BEGIN OF ls_result,
|
||||||
field_data type string,
|
field_data TYPE string,
|
||||||
begin of struc_data,
|
BEGIN OF struc_data,
|
||||||
field_more type string_table,
|
field_more TYPE string_table,
|
||||||
end of struc_data,
|
END OF struc_data,
|
||||||
end of ls_result.
|
END OF ls_result.
|
||||||
|
|
||||||
li_mapping = z2ui5_cl_ajson_mapping=>create_camel_case( iv_first_json_upper = abap_false ).
|
li_mapping = z2ui5_cl_ajson_mapping=>create_camel_case( iv_first_json_upper = abap_false ).
|
||||||
|
|
||||||
ls_result-field_data = 'field_value'.
|
ls_result-field_data = 'field_value'.
|
||||||
lv_value = 'field_more'.
|
lv_value = 'field_more'.
|
||||||
insert lv_value into table ls_result-struc_data-field_more.
|
INSERT lv_value INTO TABLE ls_result-struc_data-field_more.
|
||||||
|
|
||||||
lo_ajson = z2ui5_cl_ajson=>create_empty( ii_custom_mapping = li_mapping ).
|
lo_ajson = z2ui5_cl_ajson=>create_empty( ii_custom_mapping = li_mapping ).
|
||||||
|
|
||||||
|
@ -153,18 +157,18 @@ class ltcl_test_mappers implementation.
|
||||||
act = lo_ajson->stringify( )
|
act = lo_ajson->stringify( )
|
||||||
exp = '{"fieldData":"field_value","strucData":{"fieldMore":["field_more"]}}' ).
|
exp = '{"fieldData":"field_value","strucData":{"fieldMore":["field_more"]}}' ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method to_json_first_lower.
|
METHOD to_json_first_lower.
|
||||||
|
|
||||||
data:
|
DATA:
|
||||||
lo_ajson type ref to z2ui5_cl_ajson,
|
lo_ajson TYPE REF TO z2ui5_cl_ajson,
|
||||||
li_mapping type ref to z2ui5_if_ajson_mapping.
|
li_mapping TYPE REF TO z2ui5_if_ajson_mapping.
|
||||||
data:
|
DATA:
|
||||||
begin of ls_result,
|
BEGIN OF ls_result,
|
||||||
field_data type string,
|
field_data TYPE string,
|
||||||
end of ls_result.
|
END OF ls_result.
|
||||||
|
|
||||||
li_mapping = z2ui5_cl_ajson_mapping=>create_camel_case( ).
|
li_mapping = z2ui5_cl_ajson_mapping=>create_camel_case( ).
|
||||||
|
|
||||||
|
@ -172,16 +176,17 @@ class ltcl_test_mappers implementation.
|
||||||
|
|
||||||
lo_ajson = z2ui5_cl_ajson=>create_empty( ii_custom_mapping = li_mapping ).
|
lo_ajson = z2ui5_cl_ajson=>create_empty( ii_custom_mapping = li_mapping ).
|
||||||
|
|
||||||
lo_ajson->set( iv_path = '/' iv_val = ls_result ).
|
lo_ajson->set( iv_path = '/'
|
||||||
|
iv_val = ls_result ).
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = lo_ajson->stringify( )
|
act = lo_ajson->stringify( )
|
||||||
exp = '{"FieldData":"field_value"}' ).
|
exp = '{"FieldData":"field_value"}' ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method test_to_upper.
|
METHOD test_to_upper.
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = z2ui5_cl_ajson=>create_from(
|
act = z2ui5_cl_ajson=>create_from(
|
||||||
|
@ -195,9 +200,9 @@ class ltcl_test_mappers implementation.
|
||||||
)->stringify( )
|
)->stringify( )
|
||||||
exp = '{"A":1,"B":{"C":2}}' ).
|
exp = '{"A":1,"B":{"C":2}}' ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method test_to_lower.
|
METHOD test_to_lower.
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = z2ui5_cl_ajson=>create_from(
|
act = z2ui5_cl_ajson=>create_from(
|
||||||
|
@ -211,20 +216,20 @@ class ltcl_test_mappers implementation.
|
||||||
)->stringify( )
|
)->stringify( )
|
||||||
exp = '{"a":1,"b":{"c":2}}' ).
|
exp = '{"a":1,"b":{"c":2}}' ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method rename_by_attr.
|
METHOD rename_by_attr.
|
||||||
|
|
||||||
data lt_map type z2ui5_if_ajson_mapping=>tty_rename_map.
|
DATA lt_map TYPE z2ui5_if_ajson_mapping=>tty_rename_map.
|
||||||
field-symbols <i> like line of lt_map.
|
FIELD-SYMBOLS <i> LIKE LINE OF lt_map.
|
||||||
|
|
||||||
append initial line to lt_map assigning <i>.
|
APPEND INITIAL LINE TO lt_map ASSIGNING <i>.
|
||||||
<i>-from = 'a'.
|
<i>-from = 'a'.
|
||||||
<i>-to = 'x'.
|
<i>-to = 'x'.
|
||||||
append initial line to lt_map assigning <i>.
|
APPEND INITIAL LINE TO lt_map ASSIGNING <i>.
|
||||||
<i>-from = 'c'.
|
<i>-from = 'c'.
|
||||||
<i>-to = 'y'.
|
<i>-to = 'y'.
|
||||||
append initial line to lt_map assigning <i>.
|
APPEND INITIAL LINE TO lt_map ASSIGNING <i>.
|
||||||
<i>-from = 'd'.
|
<i>-from = 'd'.
|
||||||
<i>-to = 'z'.
|
<i>-to = 'z'.
|
||||||
|
|
||||||
|
@ -235,14 +240,14 @@ class ltcl_test_mappers implementation.
|
||||||
) )->stringify( )
|
) )->stringify( )
|
||||||
exp = '{"b":{"y":2},"x":1,"z":{"e":3}}' ).
|
exp = '{"b":{"y":2},"x":1,"z":{"e":3}}' ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method rename_by_path.
|
METHOD rename_by_path.
|
||||||
|
|
||||||
data lt_map type z2ui5_if_ajson_mapping=>tty_rename_map.
|
DATA lt_map TYPE z2ui5_if_ajson_mapping=>tty_rename_map.
|
||||||
field-symbols <i> like line of lt_map.
|
FIELD-SYMBOLS <i> LIKE LINE OF lt_map.
|
||||||
|
|
||||||
append initial line to lt_map assigning <i>.
|
APPEND INITIAL LINE TO lt_map ASSIGNING <i>.
|
||||||
<i>-from = '/b/a'.
|
<i>-from = '/b/a'.
|
||||||
<i>-to = 'x'.
|
<i>-to = 'x'.
|
||||||
|
|
||||||
|
@ -255,14 +260,14 @@ class ltcl_test_mappers implementation.
|
||||||
) )->stringify( )
|
) )->stringify( )
|
||||||
exp = '{"a":1,"b":{"x":2},"c":{"a":3}}' ).
|
exp = '{"a":1,"b":{"x":2},"c":{"a":3}}' ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method rename_by_pattern.
|
METHOD rename_by_pattern.
|
||||||
|
|
||||||
data lt_map type z2ui5_if_ajson_mapping=>tty_rename_map.
|
DATA lt_map TYPE z2ui5_if_ajson_mapping=>tty_rename_map.
|
||||||
field-symbols <i> like line of lt_map.
|
FIELD-SYMBOLS <i> LIKE LINE OF lt_map.
|
||||||
|
|
||||||
append initial line to lt_map assigning <i>.
|
APPEND INITIAL LINE TO lt_map ASSIGNING <i>.
|
||||||
<i>-from = '/*/this*'.
|
<i>-from = '/*/this*'.
|
||||||
<i>-to = 'x'.
|
<i>-to = 'x'.
|
||||||
|
|
||||||
|
@ -275,14 +280,14 @@ class ltcl_test_mappers implementation.
|
||||||
) )->stringify( )
|
) )->stringify( )
|
||||||
exp = '{"andthisnot":1,"b":{"x":2},"c":{"a":3}}' ).
|
exp = '{"andthisnot":1,"b":{"x":2},"c":{"a":3}}' ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method compound_mapper.
|
METHOD compound_mapper.
|
||||||
|
|
||||||
data lt_map type z2ui5_if_ajson_mapping=>tty_rename_map.
|
DATA lt_map TYPE z2ui5_if_ajson_mapping=>tty_rename_map.
|
||||||
field-symbols <i> like line of lt_map.
|
FIELD-SYMBOLS <i> LIKE LINE OF lt_map.
|
||||||
|
|
||||||
append initial line to lt_map assigning <i>.
|
APPEND INITIAL LINE TO lt_map ASSIGNING <i>.
|
||||||
<i>-from = '/b/a'.
|
<i>-from = '/b/a'.
|
||||||
<i>-to = 'x'.
|
<i>-to = 'x'.
|
||||||
|
|
||||||
|
@ -297,9 +302,9 @@ class ltcl_test_mappers implementation.
|
||||||
)->stringify( )
|
)->stringify( )
|
||||||
exp = '{"A":1,"B":{"X":2},"C":{"A":3}}' ).
|
exp = '{"A":1,"B":{"X":2},"C":{"A":3}}' ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method to_snake.
|
METHOD to_snake.
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = z2ui5_cl_ajson=>create_from(
|
act = z2ui5_cl_ajson=>create_from(
|
||||||
|
@ -308,9 +313,9 @@ class ltcl_test_mappers implementation.
|
||||||
)->stringify( )
|
)->stringify( )
|
||||||
exp = '{"a_b":1,"bb_c":2,"c_d":{"x_y":3},"zz":4}' ).
|
exp = '{"a_b":1,"bb_c":2,"c_d":{"x_y":3},"zz":4}' ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method to_camel.
|
METHOD to_camel.
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = z2ui5_cl_ajson=>create_from(
|
act = z2ui5_cl_ajson=>create_from(
|
||||||
|
@ -327,9 +332,9 @@ class ltcl_test_mappers implementation.
|
||||||
)->stringify( )
|
)->stringify( )
|
||||||
exp = '{"a_b":1}' ).
|
exp = '{"a_b":1}' ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method to_camel_1st_upper.
|
METHOD to_camel_1st_upper.
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = z2ui5_cl_ajson=>create_from(
|
act = z2ui5_cl_ajson=>create_from(
|
||||||
|
@ -338,54 +343,55 @@ class ltcl_test_mappers implementation.
|
||||||
)->stringify( )
|
)->stringify( )
|
||||||
exp = '{"AjBc":1,"BbC":2,"CD":{"XqYq":3},"Zz":4}' ).
|
exp = '{"AjBc":1,"BbC":2,"CD":{"XqYq":3},"Zz":4}' ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ltcl_fields definition final for testing
|
CLASS ltcl_fields DEFINITION FINAL FOR TESTING
|
||||||
duration short
|
DURATION SHORT
|
||||||
risk level harmless.
|
RISK LEVEL HARMLESS.
|
||||||
|
|
||||||
private section.
|
PRIVATE SECTION.
|
||||||
methods:
|
METHODS:
|
||||||
to_json_without_path for testing raising z2UI5_cx_ajson_error,
|
to_json_without_path FOR TESTING RAISING z2ui5_cx_ajson_error,
|
||||||
to_json_with_path for testing raising z2UI5_cx_ajson_error,
|
to_json_with_path FOR TESTING RAISING z2ui5_cx_ajson_error,
|
||||||
to_abap for testing raising z2UI5_cx_ajson_error,
|
to_abap FOR TESTING RAISING z2ui5_cx_ajson_error,
|
||||||
to_json importing iv_path type string returning value(rv_result) type string raising z2UI5_cx_ajson_error.
|
to_json IMPORTING iv_path TYPE string RETURNING VALUE(rv_result) TYPE string RAISING z2ui5_cx_ajson_error.
|
||||||
|
|
||||||
|
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
class ltcl_fields implementation.
|
CLASS ltcl_fields IMPLEMENTATION.
|
||||||
|
|
||||||
|
|
||||||
method to_abap.
|
METHOD to_abap.
|
||||||
|
|
||||||
data:
|
DATA:
|
||||||
lo_ajson type ref to z2ui5_cl_ajson,
|
lo_ajson TYPE REF TO z2ui5_cl_ajson,
|
||||||
li_mapping type ref to z2ui5_if_ajson_mapping,
|
li_mapping TYPE REF TO z2ui5_if_ajson_mapping,
|
||||||
lt_mapping_fields type z2ui5_if_ajson_mapping=>ty_mapping_fields,
|
lt_mapping_fields TYPE z2ui5_if_ajson_mapping=>ty_mapping_fields,
|
||||||
ls_mapping_field like line of lt_mapping_fields.
|
ls_mapping_field LIKE LINE OF lt_mapping_fields.
|
||||||
data:
|
DATA:
|
||||||
begin of ls_result,
|
BEGIN OF ls_result,
|
||||||
abap_field type string,
|
abap_field TYPE string,
|
||||||
field type string,
|
field TYPE string,
|
||||||
end of ls_result.
|
END OF ls_result.
|
||||||
|
|
||||||
clear ls_mapping_field.
|
CLEAR ls_mapping_field.
|
||||||
ls_mapping_field-abap = 'ABAP_FIELD'.
|
ls_mapping_field-abap = 'ABAP_FIELD'.
|
||||||
ls_mapping_field-json = 'json.field'.
|
ls_mapping_field-json = 'json.field'.
|
||||||
insert ls_mapping_field into table lt_mapping_fields.
|
INSERT ls_mapping_field INTO TABLE lt_mapping_fields.
|
||||||
|
|
||||||
li_mapping = z2ui5_cl_ajson_mapping=>create_field_mapping( lt_mapping_fields ).
|
li_mapping = z2ui5_cl_ajson_mapping=>create_field_mapping( lt_mapping_fields ).
|
||||||
|
|
||||||
lo_ajson =
|
lo_ajson =
|
||||||
z2ui5_cl_ajson=>parse( iv_json = '{"field":"value","json.field":"field_value"}' ii_custom_mapping = li_mapping ).
|
z2ui5_cl_ajson=>parse( iv_json = '{"field":"value","json.field":"field_value"}'
|
||||||
|
ii_custom_mapping = li_mapping ).
|
||||||
|
|
||||||
lo_ajson->to_abap( importing ev_container = ls_result ).
|
lo_ajson->to_abap( IMPORTING ev_container = ls_result ).
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = ls_result-abap_field
|
act = ls_result-abap_field
|
||||||
|
@ -395,44 +401,44 @@ class ltcl_fields implementation.
|
||||||
act = ls_result-field
|
act = ls_result-field
|
||||||
exp = 'value' ).
|
exp = 'value' ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method to_json_without_path.
|
METHOD to_json_without_path.
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = to_json( `/` )
|
act = to_json( `/` )
|
||||||
exp = '{"field":"value","json.field":"field_value"}' ).
|
exp = '{"field":"value","json.field":"field_value"}' ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method to_json_with_path.
|
METHOD to_json_with_path.
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = to_json( '/samplePath' )
|
act = to_json( '/samplePath' )
|
||||||
exp = '{"samplePath":{"field":"value","json.field":"field_value"}}' ).
|
exp = '{"samplePath":{"field":"value","json.field":"field_value"}}' ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method to_json.
|
METHOD to_json.
|
||||||
|
|
||||||
data:
|
DATA:
|
||||||
lo_ajson type ref to z2ui5_cl_ajson,
|
lo_ajson TYPE REF TO z2ui5_cl_ajson,
|
||||||
li_mapping type ref to z2ui5_if_ajson_mapping,
|
li_mapping TYPE REF TO z2ui5_if_ajson_mapping,
|
||||||
lt_mapping_fields type z2ui5_if_ajson_mapping=>ty_mapping_fields,
|
lt_mapping_fields TYPE z2ui5_if_ajson_mapping=>ty_mapping_fields,
|
||||||
ls_mapping_field like line of lt_mapping_fields.
|
ls_mapping_field LIKE LINE OF lt_mapping_fields.
|
||||||
data:
|
DATA:
|
||||||
begin of ls_result,
|
BEGIN OF ls_result,
|
||||||
abap_field type string,
|
abap_field TYPE string,
|
||||||
field type string,
|
field TYPE string,
|
||||||
end of ls_result.
|
END OF ls_result.
|
||||||
|
|
||||||
clear ls_mapping_field.
|
CLEAR ls_mapping_field.
|
||||||
ls_mapping_field-abap = 'ABAP_FIELD'.
|
ls_mapping_field-abap = 'ABAP_FIELD'.
|
||||||
ls_mapping_field-json = 'json.field'.
|
ls_mapping_field-json = 'json.field'.
|
||||||
insert ls_mapping_field into table lt_mapping_fields.
|
INSERT ls_mapping_field INTO TABLE lt_mapping_fields.
|
||||||
|
|
||||||
li_mapping = z2ui5_cl_ajson_mapping=>create_field_mapping( lt_mapping_fields ).
|
li_mapping = z2ui5_cl_ajson_mapping=>create_field_mapping( lt_mapping_fields ).
|
||||||
|
|
||||||
|
@ -441,39 +447,40 @@ class ltcl_fields implementation.
|
||||||
|
|
||||||
lo_ajson = z2ui5_cl_ajson=>create_empty( ii_custom_mapping = li_mapping ).
|
lo_ajson = z2ui5_cl_ajson=>create_empty( ii_custom_mapping = li_mapping ).
|
||||||
|
|
||||||
lo_ajson->set( iv_path = iv_path iv_val = ls_result ).
|
lo_ajson->set( iv_path = iv_path
|
||||||
|
iv_val = ls_result ).
|
||||||
|
|
||||||
rv_result = lo_ajson->stringify( ).
|
rv_result = lo_ajson->stringify( ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ltcl_to_lower definition final for testing
|
CLASS ltcl_to_lower DEFINITION FINAL FOR TESTING
|
||||||
duration short
|
DURATION SHORT
|
||||||
risk level harmless.
|
RISK LEVEL HARMLESS.
|
||||||
|
|
||||||
private section.
|
PRIVATE SECTION.
|
||||||
methods:
|
METHODS:
|
||||||
to_json for testing raising z2UI5_cx_ajson_error.
|
to_json FOR TESTING RAISING z2ui5_cx_ajson_error.
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
class ltcl_to_lower implementation.
|
CLASS ltcl_to_lower IMPLEMENTATION.
|
||||||
|
|
||||||
|
|
||||||
method to_json.
|
METHOD to_json.
|
||||||
|
|
||||||
data:
|
DATA:
|
||||||
lo_ajson type ref to z2ui5_cl_ajson,
|
lo_ajson TYPE REF TO z2ui5_cl_ajson,
|
||||||
li_mapping type ref to z2ui5_if_ajson_mapping.
|
li_mapping TYPE REF TO z2ui5_if_ajson_mapping.
|
||||||
data:
|
DATA:
|
||||||
begin of ls_result,
|
BEGIN OF ls_result,
|
||||||
field_data type string,
|
field_data TYPE string,
|
||||||
end of ls_result.
|
END OF ls_result.
|
||||||
|
|
||||||
li_mapping = z2ui5_cl_ajson_mapping=>create_lower_case( ).
|
li_mapping = z2ui5_cl_ajson_mapping=>create_lower_case( ).
|
||||||
|
|
||||||
|
@ -481,41 +488,42 @@ class ltcl_to_lower implementation.
|
||||||
|
|
||||||
lo_ajson = z2ui5_cl_ajson=>create_empty( ii_custom_mapping = li_mapping ).
|
lo_ajson = z2ui5_cl_ajson=>create_empty( ii_custom_mapping = li_mapping ).
|
||||||
|
|
||||||
lo_ajson->set( iv_path = '/' iv_val = ls_result ).
|
lo_ajson->set( iv_path = '/'
|
||||||
|
iv_val = ls_result ).
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = lo_ajson->stringify( )
|
act = lo_ajson->stringify( )
|
||||||
exp = '{"field_data":"field_value"}' ).
|
exp = '{"field_data":"field_value"}' ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class ltcl_to_upper definition final for testing
|
CLASS ltcl_to_upper DEFINITION FINAL FOR TESTING
|
||||||
duration short
|
DURATION SHORT
|
||||||
risk level harmless.
|
RISK LEVEL HARMLESS.
|
||||||
|
|
||||||
private section.
|
PRIVATE SECTION.
|
||||||
methods:
|
METHODS:
|
||||||
to_json for testing raising z2UI5_cx_ajson_error.
|
to_json FOR TESTING RAISING z2ui5_cx_ajson_error.
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
class ltcl_to_upper implementation.
|
CLASS ltcl_to_upper IMPLEMENTATION.
|
||||||
|
|
||||||
|
|
||||||
method to_json.
|
METHOD to_json.
|
||||||
|
|
||||||
data:
|
DATA:
|
||||||
lo_ajson type ref to z2ui5_cl_ajson,
|
lo_ajson TYPE REF TO z2ui5_cl_ajson,
|
||||||
li_mapping type ref to z2ui5_if_ajson_mapping.
|
li_mapping TYPE REF TO z2ui5_if_ajson_mapping.
|
||||||
data:
|
DATA:
|
||||||
begin of ls_result,
|
BEGIN OF ls_result,
|
||||||
field_data type string,
|
field_data TYPE string,
|
||||||
end of ls_result.
|
END OF ls_result.
|
||||||
|
|
||||||
li_mapping = z2ui5_cl_ajson_mapping=>create_upper_case( ).
|
li_mapping = z2ui5_cl_ajson_mapping=>create_upper_case( ).
|
||||||
|
|
||||||
|
@ -523,13 +531,14 @@ class ltcl_to_upper implementation.
|
||||||
|
|
||||||
lo_ajson = z2ui5_cl_ajson=>create_empty( ii_custom_mapping = li_mapping ).
|
lo_ajson = z2ui5_cl_ajson=>create_empty( ii_custom_mapping = li_mapping ).
|
||||||
|
|
||||||
lo_ajson->set( iv_path = '/' iv_val = ls_result ).
|
lo_ajson->set( iv_path = '/'
|
||||||
|
iv_val = ls_result ).
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = lo_ajson->stringify( )
|
act = lo_ajson->stringify( )
|
||||||
exp = '{"FIELD_DATA":"field_value"}' ).
|
exp = '{"FIELD_DATA":"field_value"}' ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
|
@ -1,136 +1,136 @@
|
||||||
class z2ui5_cl_ajson_utilities definition
|
CLASS z2ui5_cl_ajson_utilities DEFINITION
|
||||||
public
|
PUBLIC
|
||||||
create public .
|
CREATE PUBLIC .
|
||||||
|
|
||||||
public section.
|
PUBLIC SECTION.
|
||||||
|
|
||||||
class-methods new
|
CLASS-METHODS new
|
||||||
returning
|
RETURNING
|
||||||
value(ro_instance) type ref to z2ui5_cl_ajson_utilities.
|
VALUE(ro_instance) TYPE REF TO z2ui5_cl_ajson_utilities.
|
||||||
methods diff
|
METHODS diff
|
||||||
importing
|
IMPORTING
|
||||||
!iv_json_a type string optional
|
!iv_json_a TYPE string OPTIONAL
|
||||||
!iv_json_b type string optional
|
!iv_json_b TYPE string OPTIONAL
|
||||||
!io_json_a type ref to z2ui5_if_ajson optional
|
!io_json_a TYPE REF TO z2ui5_if_ajson OPTIONAL
|
||||||
!io_json_b type ref to z2ui5_if_ajson optional
|
!io_json_b TYPE REF TO z2ui5_if_ajson OPTIONAL
|
||||||
!iv_keep_empty_arrays type abap_bool default abap_false
|
!iv_keep_empty_arrays TYPE abap_bool DEFAULT abap_false
|
||||||
exporting
|
EXPORTING
|
||||||
!eo_insert type ref to z2ui5_if_ajson
|
!eo_insert TYPE REF TO z2ui5_if_ajson
|
||||||
!eo_delete type ref to z2ui5_if_ajson
|
!eo_delete TYPE REF TO z2ui5_if_ajson
|
||||||
!eo_change type ref to z2ui5_if_ajson
|
!eo_change TYPE REF TO z2ui5_if_ajson
|
||||||
raising
|
RAISING
|
||||||
z2UI5_cx_ajson_error .
|
z2ui5_cx_ajson_error .
|
||||||
methods merge
|
METHODS merge
|
||||||
importing
|
IMPORTING
|
||||||
!iv_json_a type string optional
|
!iv_json_a TYPE string OPTIONAL
|
||||||
!iv_json_b type string optional
|
!iv_json_b TYPE string OPTIONAL
|
||||||
!io_json_a type ref to z2ui5_if_ajson optional
|
!io_json_a TYPE REF TO z2ui5_if_ajson OPTIONAL
|
||||||
!io_json_b type ref to z2ui5_if_ajson optional
|
!io_json_b TYPE REF TO z2ui5_if_ajson OPTIONAL
|
||||||
!iv_keep_empty_arrays type abap_bool default abap_false
|
!iv_keep_empty_arrays TYPE abap_bool DEFAULT abap_false
|
||||||
returning
|
RETURNING
|
||||||
value(ro_json) type ref to z2ui5_if_ajson
|
VALUE(ro_json) TYPE REF TO z2ui5_if_ajson
|
||||||
raising
|
RAISING
|
||||||
z2UI5_cx_ajson_error .
|
z2ui5_cx_ajson_error .
|
||||||
methods sort
|
METHODS sort
|
||||||
importing
|
IMPORTING
|
||||||
!iv_json type string optional
|
!iv_json TYPE string OPTIONAL
|
||||||
!io_json type ref to z2ui5_if_ajson optional
|
!io_json TYPE REF TO z2ui5_if_ajson OPTIONAL
|
||||||
returning
|
RETURNING
|
||||||
value(rv_sorted) type string
|
VALUE(rv_sorted) TYPE string
|
||||||
raising
|
RAISING
|
||||||
z2UI5_cx_ajson_error .
|
z2ui5_cx_ajson_error .
|
||||||
methods is_equal
|
METHODS is_equal
|
||||||
importing
|
IMPORTING
|
||||||
!iv_json_a type string optional
|
!iv_json_a TYPE string OPTIONAL
|
||||||
!iv_json_b type string optional
|
!iv_json_b TYPE string OPTIONAL
|
||||||
!ii_json_a type ref to z2ui5_if_ajson optional
|
!ii_json_a TYPE REF TO z2ui5_if_ajson OPTIONAL
|
||||||
!ii_json_b type ref to z2ui5_if_ajson optional
|
!ii_json_b TYPE REF TO z2ui5_if_ajson OPTIONAL
|
||||||
returning
|
RETURNING
|
||||||
value(rv_yes) type abap_bool
|
VALUE(rv_yes) TYPE abap_bool
|
||||||
raising
|
RAISING
|
||||||
z2UI5_cx_ajson_error .
|
z2ui5_cx_ajson_error .
|
||||||
|
|
||||||
protected section.
|
PROTECTED SECTION.
|
||||||
|
|
||||||
private section.
|
PRIVATE SECTION.
|
||||||
|
|
||||||
data mo_json_a type ref to z2ui5_if_ajson .
|
DATA mo_json_a TYPE REF TO z2ui5_if_ajson .
|
||||||
data mo_json_b type ref to z2ui5_if_ajson .
|
DATA mo_json_b TYPE REF TO z2ui5_if_ajson .
|
||||||
data mo_insert type ref to z2ui5_if_ajson .
|
DATA mo_insert TYPE REF TO z2ui5_if_ajson .
|
||||||
data mo_delete type ref to z2ui5_if_ajson .
|
DATA mo_delete TYPE REF TO z2ui5_if_ajson .
|
||||||
data mo_change type ref to z2ui5_if_ajson .
|
DATA mo_change TYPE REF TO z2ui5_if_ajson .
|
||||||
|
|
||||||
methods normalize_input
|
METHODS normalize_input
|
||||||
importing
|
IMPORTING
|
||||||
!iv_json type string optional
|
!iv_json TYPE string OPTIONAL
|
||||||
!io_json type ref to z2ui5_if_ajson optional
|
!io_json TYPE REF TO z2ui5_if_ajson OPTIONAL
|
||||||
returning
|
RETURNING
|
||||||
value(ro_json) type ref to z2ui5_if_ajson
|
VALUE(ro_json) TYPE REF TO z2ui5_if_ajson
|
||||||
raising
|
RAISING
|
||||||
z2UI5_cx_ajson_error .
|
z2ui5_cx_ajson_error .
|
||||||
methods diff_a_b
|
METHODS diff_a_b
|
||||||
importing
|
IMPORTING
|
||||||
!iv_path type string
|
!iv_path TYPE string
|
||||||
raising
|
RAISING
|
||||||
z2UI5_cx_ajson_error .
|
z2ui5_cx_ajson_error .
|
||||||
methods diff_b_a
|
METHODS diff_b_a
|
||||||
importing
|
IMPORTING
|
||||||
!iv_path type string
|
!iv_path TYPE string
|
||||||
!iv_array type abap_bool default abap_false
|
!iv_array TYPE abap_bool DEFAULT abap_false
|
||||||
raising
|
RAISING
|
||||||
z2UI5_cx_ajson_error .
|
z2ui5_cx_ajson_error .
|
||||||
methods delete_empty_nodes
|
METHODS delete_empty_nodes
|
||||||
importing
|
IMPORTING
|
||||||
!io_json type ref to z2ui5_if_ajson
|
!io_json TYPE REF TO z2ui5_if_ajson
|
||||||
!iv_keep_empty_arrays type abap_bool
|
!iv_keep_empty_arrays TYPE abap_bool
|
||||||
raising
|
RAISING
|
||||||
z2UI5_cx_ajson_error .
|
z2ui5_cx_ajson_error .
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CLASS Z2UI5_CL_AJSON_UTILITIES IMPLEMENTATION.
|
CLASS z2ui5_cl_ajson_utilities IMPLEMENTATION.
|
||||||
|
|
||||||
|
|
||||||
method delete_empty_nodes.
|
METHOD delete_empty_nodes.
|
||||||
|
|
||||||
data ls_json_tree like line of io_json->mt_json_tree.
|
DATA ls_json_tree LIKE LINE OF io_json->mt_json_tree.
|
||||||
data lv_done type abap_bool.
|
DATA lv_done TYPE abap_bool.
|
||||||
|
|
||||||
do.
|
DO.
|
||||||
lv_done = abap_true.
|
lv_done = abap_true.
|
||||||
|
|
||||||
if iv_keep_empty_arrays = abap_false.
|
IF iv_keep_empty_arrays = abap_false.
|
||||||
loop at io_json->mt_json_tree into ls_json_tree
|
LOOP AT io_json->mt_json_tree INTO ls_json_tree
|
||||||
where type = z2ui5_if_ajson_types=>node_type-array and children = 0.
|
WHERE type = z2ui5_if_ajson_types=>node_type-array AND children = 0.
|
||||||
|
|
||||||
io_json->delete( ls_json_tree-path && ls_json_tree-name ).
|
io_json->delete( ls_json_tree-path && ls_json_tree-name ).
|
||||||
|
|
||||||
endloop.
|
ENDLOOP.
|
||||||
if sy-subrc = 0.
|
IF sy-subrc = 0.
|
||||||
lv_done = abap_false.
|
lv_done = abap_false.
|
||||||
endif.
|
ENDIF.
|
||||||
endif.
|
ENDIF.
|
||||||
|
|
||||||
loop at io_json->mt_json_tree into ls_json_tree
|
LOOP AT io_json->mt_json_tree INTO ls_json_tree
|
||||||
where type = z2ui5_if_ajson_types=>node_type-object and children = 0.
|
WHERE type = z2ui5_if_ajson_types=>node_type-object AND children = 0.
|
||||||
|
|
||||||
io_json->delete( ls_json_tree-path && ls_json_tree-name ).
|
io_json->delete( ls_json_tree-path && ls_json_tree-name ).
|
||||||
|
|
||||||
endloop.
|
ENDLOOP.
|
||||||
if sy-subrc = 0.
|
IF sy-subrc = 0.
|
||||||
lv_done = abap_false.
|
lv_done = abap_false.
|
||||||
endif.
|
ENDIF.
|
||||||
|
|
||||||
if lv_done = abap_true.
|
IF lv_done = abap_true.
|
||||||
exit. " nothing else to delete
|
EXIT. " nothing else to delete
|
||||||
endif.
|
ENDIF.
|
||||||
enddo.
|
ENDDO.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method diff.
|
METHOD diff.
|
||||||
|
|
||||||
mo_json_a = normalize_input(
|
mo_json_a = normalize_input(
|
||||||
iv_json = iv_json_a
|
iv_json = iv_json_a
|
||||||
|
@ -161,162 +161,162 @@ CLASS Z2UI5_CL_AJSON_UTILITIES IMPLEMENTATION.
|
||||||
io_json = eo_change
|
io_json = eo_change
|
||||||
iv_keep_empty_arrays = iv_keep_empty_arrays ).
|
iv_keep_empty_arrays = iv_keep_empty_arrays ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method diff_a_b.
|
METHOD diff_a_b.
|
||||||
|
|
||||||
data:
|
DATA:
|
||||||
lv_path_a type string,
|
lv_path_a TYPE string,
|
||||||
lv_path_b type string.
|
lv_path_b TYPE string.
|
||||||
|
|
||||||
field-symbols:
|
FIELD-SYMBOLS:
|
||||||
<node_a> like line of mo_json_a->mt_json_tree,
|
<node_a> LIKE LINE OF mo_json_a->mt_json_tree,
|
||||||
<node_b> like line of mo_json_a->mt_json_tree.
|
<node_b> LIKE LINE OF mo_json_a->mt_json_tree.
|
||||||
|
|
||||||
loop at mo_json_a->mt_json_tree assigning <node_a> where path = iv_path.
|
LOOP AT mo_json_a->mt_json_tree ASSIGNING <node_a> WHERE path = iv_path.
|
||||||
lv_path_a = <node_a>-path && <node_a>-name && '/'.
|
lv_path_a = <node_a>-path && <node_a>-name && '/'.
|
||||||
|
|
||||||
read table mo_json_b->mt_json_tree assigning <node_b>
|
READ TABLE mo_json_b->mt_json_tree ASSIGNING <node_b>
|
||||||
with table key path = <node_a>-path name = <node_a>-name.
|
WITH TABLE KEY path = <node_a>-path name = <node_a>-name.
|
||||||
if sy-subrc = 0.
|
IF sy-subrc = 0.
|
||||||
lv_path_b = <node_b>-path && <node_b>-name && '/'.
|
lv_path_b = <node_b>-path && <node_b>-name && '/'.
|
||||||
|
|
||||||
if <node_a>-type = <node_b>-type.
|
IF <node_a>-type = <node_b>-type.
|
||||||
case <node_a>-type.
|
CASE <node_a>-type.
|
||||||
when z2ui5_if_ajson_types=>node_type-array.
|
WHEN z2ui5_if_ajson_types=>node_type-array.
|
||||||
mo_insert->touch_array( lv_path_a ).
|
mo_insert->touch_array( lv_path_a ).
|
||||||
mo_change->touch_array( lv_path_a ).
|
mo_change->touch_array( lv_path_a ).
|
||||||
mo_delete->touch_array( lv_path_a ).
|
mo_delete->touch_array( lv_path_a ).
|
||||||
diff_a_b( lv_path_a ).
|
diff_a_b( lv_path_a ).
|
||||||
when z2ui5_if_ajson_types=>node_type-object.
|
WHEN z2ui5_if_ajson_types=>node_type-object.
|
||||||
diff_a_b( lv_path_a ).
|
diff_a_b( lv_path_a ).
|
||||||
when others.
|
WHEN OTHERS.
|
||||||
if <node_a>-value <> <node_b>-value.
|
IF <node_a>-value <> <node_b>-value.
|
||||||
" save as changed value
|
" save as changed value
|
||||||
mo_change->set(
|
mo_change->set(
|
||||||
iv_path = lv_path_b
|
iv_path = lv_path_b
|
||||||
iv_val = <node_b>-value
|
iv_val = <node_b>-value
|
||||||
iv_node_type = <node_b>-type ).
|
iv_node_type = <node_b>-type ).
|
||||||
endif.
|
ENDIF.
|
||||||
endcase.
|
ENDCASE.
|
||||||
else.
|
ELSE.
|
||||||
" save changed type as delete + insert
|
" save changed type as delete + insert
|
||||||
case <node_a>-type.
|
CASE <node_a>-type.
|
||||||
when z2ui5_if_ajson_types=>node_type-array.
|
WHEN z2ui5_if_ajson_types=>node_type-array.
|
||||||
mo_delete->touch_array( lv_path_a ).
|
mo_delete->touch_array( lv_path_a ).
|
||||||
diff_a_b( lv_path_a ).
|
diff_a_b( lv_path_a ).
|
||||||
when z2ui5_if_ajson_types=>node_type-object.
|
WHEN z2ui5_if_ajson_types=>node_type-object.
|
||||||
diff_a_b( lv_path_a ).
|
diff_a_b( lv_path_a ).
|
||||||
when others.
|
WHEN OTHERS.
|
||||||
mo_delete->set(
|
mo_delete->set(
|
||||||
iv_path = lv_path_a
|
iv_path = lv_path_a
|
||||||
iv_val = <node_a>-value
|
iv_val = <node_a>-value
|
||||||
iv_node_type = <node_a>-type ).
|
iv_node_type = <node_a>-type ).
|
||||||
endcase.
|
ENDCASE.
|
||||||
case <node_b>-type.
|
CASE <node_b>-type.
|
||||||
when z2ui5_if_ajson_types=>node_type-array.
|
WHEN z2ui5_if_ajson_types=>node_type-array.
|
||||||
mo_insert->touch_array( lv_path_b ).
|
mo_insert->touch_array( lv_path_b ).
|
||||||
diff_b_a( lv_path_b ).
|
diff_b_a( lv_path_b ).
|
||||||
when z2ui5_if_ajson_types=>node_type-object.
|
WHEN z2ui5_if_ajson_types=>node_type-object.
|
||||||
diff_b_a( lv_path_b ).
|
diff_b_a( lv_path_b ).
|
||||||
when others.
|
WHEN OTHERS.
|
||||||
mo_insert->set(
|
mo_insert->set(
|
||||||
iv_path = lv_path_b
|
iv_path = lv_path_b
|
||||||
iv_val = <node_b>-value
|
iv_val = <node_b>-value
|
||||||
iv_node_type = <node_b>-type ).
|
iv_node_type = <node_b>-type ).
|
||||||
endcase.
|
ENDCASE.
|
||||||
endif.
|
ENDIF.
|
||||||
else.
|
ELSE.
|
||||||
" save as delete
|
" save as delete
|
||||||
case <node_a>-type.
|
CASE <node_a>-type.
|
||||||
when z2ui5_if_ajson_types=>node_type-array.
|
WHEN z2ui5_if_ajson_types=>node_type-array.
|
||||||
mo_delete->touch_array( lv_path_a ).
|
mo_delete->touch_array( lv_path_a ).
|
||||||
diff_a_b( lv_path_a ).
|
diff_a_b( lv_path_a ).
|
||||||
when z2ui5_if_ajson_types=>node_type-object.
|
WHEN z2ui5_if_ajson_types=>node_type-object.
|
||||||
diff_a_b( lv_path_a ).
|
diff_a_b( lv_path_a ).
|
||||||
when others.
|
WHEN OTHERS.
|
||||||
mo_delete->set(
|
mo_delete->set(
|
||||||
iv_path = lv_path_a
|
iv_path = lv_path_a
|
||||||
iv_val = <node_a>-value
|
iv_val = <node_a>-value
|
||||||
iv_node_type = <node_a>-type ).
|
iv_node_type = <node_a>-type ).
|
||||||
endcase.
|
ENDCASE.
|
||||||
endif.
|
ENDIF.
|
||||||
endloop.
|
ENDLOOP.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method diff_b_a.
|
METHOD diff_b_a.
|
||||||
|
|
||||||
data lv_path type string.
|
DATA lv_path TYPE string.
|
||||||
|
|
||||||
field-symbols <node_b> like line of mo_json_b->mt_json_tree.
|
FIELD-SYMBOLS <node_b> LIKE LINE OF mo_json_b->mt_json_tree.
|
||||||
|
|
||||||
loop at mo_json_b->mt_json_tree assigning <node_b> where path = iv_path.
|
LOOP AT mo_json_b->mt_json_tree ASSIGNING <node_b> WHERE path = iv_path.
|
||||||
lv_path = <node_b>-path && <node_b>-name && '/'.
|
lv_path = <node_b>-path && <node_b>-name && '/'.
|
||||||
|
|
||||||
case <node_b>-type.
|
CASE <node_b>-type.
|
||||||
when z2ui5_if_ajson_types=>node_type-array.
|
WHEN z2ui5_if_ajson_types=>node_type-array.
|
||||||
mo_insert->touch_array( lv_path ).
|
mo_insert->touch_array( lv_path ).
|
||||||
diff_b_a(
|
diff_b_a(
|
||||||
iv_path = lv_path
|
iv_path = lv_path
|
||||||
iv_array = abap_true ).
|
iv_array = abap_true ).
|
||||||
when z2ui5_if_ajson_types=>node_type-object.
|
WHEN z2ui5_if_ajson_types=>node_type-object.
|
||||||
diff_b_a( lv_path ).
|
diff_b_a( lv_path ).
|
||||||
when others.
|
WHEN OTHERS.
|
||||||
if iv_array = abap_false.
|
IF iv_array = abap_false.
|
||||||
read table mo_json_a->mt_json_tree transporting no fields
|
READ TABLE mo_json_a->mt_json_tree TRANSPORTING NO FIELDS
|
||||||
with table key path = <node_b>-path name = <node_b>-name.
|
WITH TABLE KEY path = <node_b>-path name = <node_b>-name.
|
||||||
if sy-subrc <> 0.
|
IF sy-subrc <> 0.
|
||||||
" save as insert
|
" save as insert
|
||||||
mo_insert->set(
|
mo_insert->set(
|
||||||
iv_path = lv_path
|
iv_path = lv_path
|
||||||
iv_val = <node_b>-value
|
iv_val = <node_b>-value
|
||||||
iv_node_type = <node_b>-type ).
|
iv_node_type = <node_b>-type ).
|
||||||
endif.
|
ENDIF.
|
||||||
else.
|
ELSE.
|
||||||
read table mo_insert->mt_json_tree transporting no fields
|
READ TABLE mo_insert->mt_json_tree TRANSPORTING NO FIELDS
|
||||||
with key path = <node_b>-path value = <node_b>-value.
|
WITH KEY path = <node_b>-path value = <node_b>-value.
|
||||||
if sy-subrc <> 0.
|
IF sy-subrc <> 0.
|
||||||
" save as new array value
|
" save as new array value
|
||||||
mo_insert->push(
|
mo_insert->push(
|
||||||
iv_path = iv_path
|
iv_path = iv_path
|
||||||
iv_val = <node_b>-value ).
|
iv_val = <node_b>-value ).
|
||||||
endif.
|
ENDIF.
|
||||||
endif.
|
ENDIF.
|
||||||
endcase.
|
ENDCASE.
|
||||||
endloop.
|
ENDLOOP.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method is_equal.
|
METHOD is_equal.
|
||||||
|
|
||||||
data li_ins type ref to z2ui5_if_ajson.
|
DATA li_ins TYPE REF TO z2ui5_if_ajson.
|
||||||
data li_del type ref to z2ui5_if_ajson.
|
DATA li_del TYPE REF TO z2ui5_if_ajson.
|
||||||
data li_mod type ref to z2ui5_if_ajson.
|
DATA li_mod TYPE REF TO z2ui5_if_ajson.
|
||||||
|
|
||||||
diff(
|
diff(
|
||||||
exporting
|
EXPORTING
|
||||||
iv_json_a = iv_json_a
|
iv_json_a = iv_json_a
|
||||||
iv_json_b = iv_json_b
|
iv_json_b = iv_json_b
|
||||||
io_json_a = ii_json_a
|
io_json_a = ii_json_a
|
||||||
io_json_b = ii_json_b
|
io_json_b = ii_json_b
|
||||||
importing
|
IMPORTING
|
||||||
eo_insert = li_ins
|
eo_insert = li_ins
|
||||||
eo_delete = li_del
|
eo_delete = li_del
|
||||||
eo_change = li_mod ).
|
eo_change = li_mod ).
|
||||||
|
|
||||||
rv_yes = boolc(
|
rv_yes = boolc(
|
||||||
li_ins->is_empty( ) = abap_true and
|
li_ins->is_empty( ) = abap_true AND
|
||||||
li_del->is_empty( ) = abap_true and
|
li_del->is_empty( ) = abap_true AND
|
||||||
li_mod->is_empty( ) = abap_true ).
|
li_mod->is_empty( ) = abap_true ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method merge.
|
METHOD merge.
|
||||||
|
|
||||||
mo_json_a = normalize_input(
|
mo_json_a = normalize_input(
|
||||||
iv_json = iv_json_a
|
iv_json = iv_json_a
|
||||||
|
@ -338,34 +338,34 @@ CLASS Z2UI5_CL_AJSON_UTILITIES IMPLEMENTATION.
|
||||||
io_json = ro_json
|
io_json = ro_json
|
||||||
iv_keep_empty_arrays = iv_keep_empty_arrays ).
|
iv_keep_empty_arrays = iv_keep_empty_arrays ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method new.
|
METHOD new.
|
||||||
create object ro_instance.
|
CREATE OBJECT ro_instance.
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method normalize_input.
|
METHOD normalize_input.
|
||||||
|
|
||||||
if boolc( iv_json is initial ) = boolc( io_json is initial ).
|
IF boolc( iv_json IS INITIAL ) = boolc( io_json IS INITIAL ).
|
||||||
z2UI5_cx_ajson_error=>raise( 'Either supply JSON string or instance, but not both' ).
|
z2ui5_cx_ajson_error=>raise( 'Either supply JSON string or instance, but not both' ).
|
||||||
endif.
|
ENDIF.
|
||||||
|
|
||||||
if iv_json is not initial.
|
IF iv_json IS NOT INITIAL.
|
||||||
ro_json = z2ui5_cl_ajson=>parse( iv_json ).
|
ro_json = z2ui5_cl_ajson=>parse( iv_json ).
|
||||||
elseif io_json is not initial.
|
ELSEIF io_json IS NOT INITIAL.
|
||||||
ro_json = io_json.
|
ro_json = io_json.
|
||||||
else.
|
ELSE.
|
||||||
z2UI5_cx_ajson_error=>raise( 'Supply either JSON string or instance' ).
|
z2ui5_cx_ajson_error=>raise( 'Supply either JSON string or instance' ).
|
||||||
endif.
|
ENDIF.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
|
|
||||||
method sort.
|
METHOD sort.
|
||||||
|
|
||||||
data lo_json type ref to z2ui5_if_ajson.
|
DATA lo_json TYPE REF TO z2ui5_if_ajson.
|
||||||
|
|
||||||
lo_json = normalize_input(
|
lo_json = normalize_input(
|
||||||
iv_json = iv_json
|
iv_json = iv_json
|
||||||
|
@ -374,5 +374,5 @@ CLASS Z2UI5_CL_AJSON_UTILITIES IMPLEMENTATION.
|
||||||
" Nodes are parsed into a sorted table, so no explicit sorting required
|
" Nodes are parsed into a sorted table, so no explicit sorting required
|
||||||
rv_sorted = lo_json->stringify( 2 ).
|
rv_sorted = lo_json->stringify( 2 ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
ENDCLASS.
|
ENDCLASS.
|
||||||
|
|
|
@ -2,72 +2,72 @@
|
||||||
* UTIL
|
* UTIL
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
|
|
||||||
class lcl_nodes_helper definition final.
|
CLASS lcl_nodes_helper DEFINITION FINAL.
|
||||||
public section.
|
PUBLIC SECTION.
|
||||||
|
|
||||||
data mt_nodes type z2ui5_if_ajson_types=>ty_nodes_tt read-only.
|
DATA mt_nodes TYPE z2ui5_if_ajson_types=>ty_nodes_tt READ-ONLY.
|
||||||
|
|
||||||
methods add
|
METHODS add
|
||||||
importing
|
IMPORTING
|
||||||
iv_str type string.
|
iv_str TYPE string.
|
||||||
methods sorted
|
METHODS sorted
|
||||||
returning
|
RETURNING
|
||||||
value(rt_nodes) type z2ui5_if_ajson_types=>ty_nodes_ts.
|
VALUE(rt_nodes) TYPE z2ui5_if_ajson_types=>ty_nodes_ts.
|
||||||
|
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
||||||
class lcl_nodes_helper implementation.
|
CLASS lcl_nodes_helper IMPLEMENTATION.
|
||||||
method add.
|
METHOD add.
|
||||||
|
|
||||||
field-symbols <n> like line of mt_nodes.
|
FIELD-SYMBOLS <n> LIKE LINE OF mt_nodes.
|
||||||
data lv_children type string.
|
DATA lv_children TYPE string.
|
||||||
data lv_index type string.
|
DATA lv_index TYPE string.
|
||||||
|
|
||||||
append initial line to mt_nodes assigning <n>.
|
APPEND INITIAL LINE TO mt_nodes ASSIGNING <n>.
|
||||||
|
|
||||||
split iv_str at '|' into
|
SPLIT iv_str AT '|' INTO
|
||||||
<n>-path
|
<n>-path
|
||||||
<n>-name
|
<n>-name
|
||||||
<n>-type
|
<n>-type
|
||||||
<n>-value
|
<n>-value
|
||||||
lv_index
|
lv_index
|
||||||
lv_children.
|
lv_children.
|
||||||
condense <n>-path.
|
CONDENSE <n>-path.
|
||||||
condense <n>-name.
|
CONDENSE <n>-name.
|
||||||
condense <n>-type.
|
CONDENSE <n>-type.
|
||||||
condense <n>-value.
|
CONDENSE <n>-value.
|
||||||
<n>-index = lv_index.
|
<n>-index = lv_index.
|
||||||
<n>-children = lv_children.
|
<n>-children = lv_children.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method sorted.
|
METHOD sorted.
|
||||||
rt_nodes = mt_nodes.
|
rt_nodes = mt_nodes.
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
* PARSER
|
* PARSER
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
|
|
||||||
class ltcl_parser_test definition final
|
CLASS ltcl_parser_test DEFINITION FINAL
|
||||||
for testing
|
FOR TESTING
|
||||||
risk level harmless
|
RISK LEVEL HARMLESS
|
||||||
duration short.
|
DURATION SHORT.
|
||||||
|
|
||||||
public section.
|
PUBLIC SECTION.
|
||||||
|
|
||||||
class-methods sample_json
|
CLASS-METHODS sample_json
|
||||||
importing
|
IMPORTING
|
||||||
iv_separator type string optional
|
iv_separator TYPE string OPTIONAL
|
||||||
returning
|
RETURNING
|
||||||
value(rv_json) type string.
|
VALUE(rv_json) TYPE string.
|
||||||
|
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
||||||
class ltcl_parser_test implementation.
|
CLASS ltcl_parser_test IMPLEMENTATION.
|
||||||
|
|
||||||
method sample_json.
|
METHOD sample_json.
|
||||||
|
|
||||||
rv_json =
|
rv_json =
|
||||||
'{\n' &&
|
'{\n' &&
|
||||||
|
@ -108,46 +108,46 @@ class ltcl_parser_test implementation.
|
||||||
' ]\n' &&
|
' ]\n' &&
|
||||||
'}'.
|
'}'.
|
||||||
|
|
||||||
replace all occurrences of '\n' in rv_json with iv_separator.
|
REPLACE ALL OCCURRENCES OF '\n' IN rv_json WITH iv_separator.
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
* JSON UTILITIES
|
* JSON UTILITIES
|
||||||
**********************************************************************
|
**********************************************************************
|
||||||
|
|
||||||
class ltcl_json_utils definition
|
CLASS ltcl_json_utils DEFINITION
|
||||||
for testing
|
FOR TESTING
|
||||||
risk level harmless
|
RISK LEVEL HARMLESS
|
||||||
duration short
|
DURATION SHORT
|
||||||
final.
|
FINAL.
|
||||||
|
|
||||||
private section.
|
PRIVATE SECTION.
|
||||||
|
|
||||||
methods json_diff for testing raising z2UI5_cx_ajson_error.
|
METHODS json_diff FOR TESTING RAISING z2ui5_cx_ajson_error.
|
||||||
methods json_diff_types for testing raising z2UI5_cx_ajson_error.
|
METHODS json_diff_types FOR TESTING RAISING z2ui5_cx_ajson_error.
|
||||||
methods json_diff_arrays for testing raising z2UI5_cx_ajson_error.
|
METHODS json_diff_arrays FOR TESTING RAISING z2ui5_cx_ajson_error.
|
||||||
methods json_merge for testing raising z2UI5_cx_ajson_error.
|
METHODS json_merge FOR TESTING RAISING z2ui5_cx_ajson_error.
|
||||||
methods json_sort for testing raising z2UI5_cx_ajson_error.
|
METHODS json_sort FOR TESTING RAISING z2ui5_cx_ajson_error.
|
||||||
methods is_equal for testing raising z2UI5_cx_ajson_error.
|
METHODS is_equal FOR TESTING RAISING z2ui5_cx_ajson_error.
|
||||||
|
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
||||||
class ltcl_json_utils implementation.
|
CLASS ltcl_json_utils IMPLEMENTATION.
|
||||||
|
|
||||||
method json_diff.
|
METHOD json_diff.
|
||||||
|
|
||||||
data:
|
DATA:
|
||||||
lv_json type string,
|
lv_json TYPE string,
|
||||||
lo_util type ref to z2ui5_cl_ajson_utilities,
|
lo_util TYPE REF TO z2ui5_cl_ajson_utilities,
|
||||||
lo_insert type ref to z2ui5_if_ajson,
|
lo_insert TYPE REF TO z2ui5_if_ajson,
|
||||||
lo_delete type ref to z2ui5_if_ajson,
|
lo_delete TYPE REF TO z2ui5_if_ajson,
|
||||||
lo_change type ref to z2ui5_if_ajson,
|
lo_change TYPE REF TO z2ui5_if_ajson,
|
||||||
lo_insert_exp type ref to lcl_nodes_helper,
|
lo_insert_exp TYPE REF TO lcl_nodes_helper,
|
||||||
lo_delete_exp type ref to lcl_nodes_helper,
|
lo_delete_exp TYPE REF TO lcl_nodes_helper,
|
||||||
lo_change_exp type ref to lcl_nodes_helper.
|
lo_change_exp TYPE REF TO lcl_nodes_helper.
|
||||||
|
|
||||||
lv_json =
|
lv_json =
|
||||||
'{\n' &&
|
'{\n' &&
|
||||||
|
@ -190,9 +190,9 @@ class ltcl_json_utils implementation.
|
||||||
' ]\n' &&
|
' ]\n' &&
|
||||||
'}'.
|
'}'.
|
||||||
|
|
||||||
replace all occurrences of '\n' in lv_json with cl_abap_char_utilities=>newline.
|
REPLACE ALL OCCURRENCES OF '\n' IN lv_json WITH cl_abap_char_utilities=>newline.
|
||||||
|
|
||||||
create object lo_insert_exp.
|
CREATE OBJECT lo_insert_exp.
|
||||||
lo_insert_exp->add( ' | |object | |0|3' ).
|
lo_insert_exp->add( ' | |object | |0|3' ).
|
||||||
lo_insert_exp->add( '/ |boolean |str |true |0|0' ). " changed type (insert new)
|
lo_insert_exp->add( '/ |boolean |str |true |0|0' ). " changed type (insert new)
|
||||||
lo_insert_exp->add( '/ |issues |array | |0|1' ).
|
lo_insert_exp->add( '/ |issues |array | |0|1' ).
|
||||||
|
@ -201,7 +201,7 @@ class ltcl_json_utils implementation.
|
||||||
lo_insert_exp->add( '/issues/1/ |end |object | |0|1' ).
|
lo_insert_exp->add( '/issues/1/ |end |object | |0|1' ).
|
||||||
lo_insert_exp->add( '/issues/1/end/ |new |num |1 |0|0' ). " array insert
|
lo_insert_exp->add( '/issues/1/end/ |new |num |1 |0|0' ). " array insert
|
||||||
|
|
||||||
create object lo_delete_exp.
|
CREATE OBJECT lo_delete_exp.
|
||||||
lo_delete_exp->add( ' | |object | |0|3' ).
|
lo_delete_exp->add( ' | |object | |0|3' ).
|
||||||
lo_delete_exp->add( '/ |boolean |bool |true |0|0' ). " changed type (delete old)
|
lo_delete_exp->add( '/ |boolean |bool |true |0|0' ). " changed type (delete old)
|
||||||
lo_delete_exp->add( '/ |false |bool |false |0|0' ). " delete
|
lo_delete_exp->add( '/ |false |bool |false |0|0' ). " delete
|
||||||
|
@ -210,7 +210,7 @@ class ltcl_json_utils implementation.
|
||||||
lo_delete_exp->add( '/issues/1/ |end |object | |0|1' ).
|
lo_delete_exp->add( '/issues/1/ |end |object | |0|1' ).
|
||||||
lo_delete_exp->add( '/issues/1/end/ |row |num |4 |0|0' ). " array delete
|
lo_delete_exp->add( '/issues/1/end/ |row |num |4 |0|0' ). " array delete
|
||||||
|
|
||||||
create object lo_change_exp.
|
CREATE OBJECT lo_change_exp.
|
||||||
lo_change_exp->add( ' | |object | |0|2' ).
|
lo_change_exp->add( ' | |object | |0|2' ).
|
||||||
lo_change_exp->add( '/ |issues |array | |0|1' ).
|
lo_change_exp->add( '/ |issues |array | |0|1' ).
|
||||||
lo_change_exp->add( '/ |number |num |789 |0|0' ). " changed value
|
lo_change_exp->add( '/ |number |num |789 |0|0' ). " changed value
|
||||||
|
@ -218,13 +218,13 @@ class ltcl_json_utils implementation.
|
||||||
lo_change_exp->add( '/issues/1/ |start |object | |0|1' ).
|
lo_change_exp->add( '/issues/1/ |start |object | |0|1' ).
|
||||||
lo_change_exp->add( '/issues/1/start/|row |num |5 |0|0' ). " array change
|
lo_change_exp->add( '/issues/1/start/|row |num |5 |0|0' ). " array change
|
||||||
|
|
||||||
create object lo_util.
|
CREATE OBJECT lo_util.
|
||||||
|
|
||||||
lo_util->diff(
|
lo_util->diff(
|
||||||
exporting
|
EXPORTING
|
||||||
iv_json_a = ltcl_parser_test=>sample_json( )
|
iv_json_a = ltcl_parser_test=>sample_json( )
|
||||||
iv_json_b = lv_json
|
iv_json_b = lv_json
|
||||||
importing
|
IMPORTING
|
||||||
eo_insert = lo_insert
|
eo_insert = lo_insert
|
||||||
eo_delete = lo_delete
|
eo_delete = lo_delete
|
||||||
eo_change = lo_change ).
|
eo_change = lo_change ).
|
||||||
|
@ -241,19 +241,19 @@ class ltcl_json_utils implementation.
|
||||||
act = lo_change->mt_json_tree
|
act = lo_change->mt_json_tree
|
||||||
exp = lo_change_exp->mt_nodes ).
|
exp = lo_change_exp->mt_nodes ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method json_diff_types.
|
METHOD json_diff_types.
|
||||||
|
|
||||||
data:
|
DATA:
|
||||||
lv_json_a type string,
|
lv_json_a TYPE string,
|
||||||
lv_json_b type string,
|
lv_json_b TYPE string,
|
||||||
lo_util type ref to z2ui5_cl_ajson_utilities,
|
lo_util TYPE REF TO z2ui5_cl_ajson_utilities,
|
||||||
lo_insert type ref to z2ui5_if_ajson,
|
lo_insert TYPE REF TO z2ui5_if_ajson,
|
||||||
lo_delete type ref to z2ui5_if_ajson,
|
lo_delete TYPE REF TO z2ui5_if_ajson,
|
||||||
lo_change type ref to z2ui5_if_ajson,
|
lo_change TYPE REF TO z2ui5_if_ajson,
|
||||||
lo_insert_exp type ref to lcl_nodes_helper,
|
lo_insert_exp TYPE REF TO lcl_nodes_helper,
|
||||||
lo_delete_exp type ref to lcl_nodes_helper.
|
lo_delete_exp TYPE REF TO lcl_nodes_helper.
|
||||||
|
|
||||||
" Change single value to array
|
" Change single value to array
|
||||||
lv_json_a =
|
lv_json_a =
|
||||||
|
@ -272,27 +272,27 @@ class ltcl_json_utils implementation.
|
||||||
' "number": 123\n' &&
|
' "number": 123\n' &&
|
||||||
'}'.
|
'}'.
|
||||||
|
|
||||||
replace all occurrences of '\n' in lv_json_a with cl_abap_char_utilities=>newline.
|
REPLACE ALL OCCURRENCES OF '\n' IN lv_json_a WITH cl_abap_char_utilities=>newline.
|
||||||
replace all occurrences of '\n' in lv_json_b with cl_abap_char_utilities=>newline.
|
REPLACE ALL OCCURRENCES OF '\n' IN lv_json_b WITH cl_abap_char_utilities=>newline.
|
||||||
|
|
||||||
create object lo_insert_exp.
|
CREATE OBJECT lo_insert_exp.
|
||||||
lo_insert_exp->add( ' | |object | |0|1' ).
|
lo_insert_exp->add( ' | |object | |0|1' ).
|
||||||
lo_insert_exp->add( '/ |string |array | |0|3' ).
|
lo_insert_exp->add( '/ |string |array | |0|3' ).
|
||||||
lo_insert_exp->add( '/string/ |1 |str |a |1|0' ).
|
lo_insert_exp->add( '/string/ |1 |str |a |1|0' ).
|
||||||
lo_insert_exp->add( '/string/ |2 |str |b |2|0' ).
|
lo_insert_exp->add( '/string/ |2 |str |b |2|0' ).
|
||||||
lo_insert_exp->add( '/string/ |3 |str |c |3|0' ).
|
lo_insert_exp->add( '/string/ |3 |str |c |3|0' ).
|
||||||
|
|
||||||
create object lo_delete_exp.
|
CREATE OBJECT lo_delete_exp.
|
||||||
lo_delete_exp->add( ' | |object | |0|1' ).
|
lo_delete_exp->add( ' | |object | |0|1' ).
|
||||||
lo_delete_exp->add( '/ |string |str |abc |0|0' ).
|
lo_delete_exp->add( '/ |string |str |abc |0|0' ).
|
||||||
|
|
||||||
create object lo_util.
|
CREATE OBJECT lo_util.
|
||||||
|
|
||||||
lo_util->diff(
|
lo_util->diff(
|
||||||
exporting
|
EXPORTING
|
||||||
iv_json_a = lv_json_a
|
iv_json_a = lv_json_a
|
||||||
iv_json_b = lv_json_b
|
iv_json_b = lv_json_b
|
||||||
importing
|
IMPORTING
|
||||||
eo_insert = lo_insert
|
eo_insert = lo_insert
|
||||||
eo_delete = lo_delete
|
eo_delete = lo_delete
|
||||||
eo_change = lo_change ).
|
eo_change = lo_change ).
|
||||||
|
@ -311,10 +311,10 @@ class ltcl_json_utils implementation.
|
||||||
|
|
||||||
" Change array to single value
|
" Change array to single value
|
||||||
lo_util->diff(
|
lo_util->diff(
|
||||||
exporting
|
EXPORTING
|
||||||
iv_json_a = lv_json_b
|
iv_json_a = lv_json_b
|
||||||
iv_json_b = lv_json_a
|
iv_json_b = lv_json_a
|
||||||
importing
|
IMPORTING
|
||||||
eo_insert = lo_insert
|
eo_insert = lo_insert
|
||||||
eo_delete = lo_delete
|
eo_delete = lo_delete
|
||||||
eo_change = lo_change ).
|
eo_change = lo_change ).
|
||||||
|
@ -331,18 +331,18 @@ class ltcl_json_utils implementation.
|
||||||
act = lines( lo_change->mt_json_tree )
|
act = lines( lo_change->mt_json_tree )
|
||||||
exp = 0 ).
|
exp = 0 ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method json_diff_arrays.
|
METHOD json_diff_arrays.
|
||||||
|
|
||||||
data:
|
DATA:
|
||||||
lv_json_a type string,
|
lv_json_a TYPE string,
|
||||||
lv_json_b type string,
|
lv_json_b TYPE string,
|
||||||
lo_util type ref to z2ui5_cl_ajson_utilities,
|
lo_util TYPE REF TO z2ui5_cl_ajson_utilities,
|
||||||
lo_insert type ref to z2ui5_if_ajson,
|
lo_insert TYPE REF TO z2ui5_if_ajson,
|
||||||
lo_delete type ref to z2ui5_if_ajson,
|
lo_delete TYPE REF TO z2ui5_if_ajson,
|
||||||
lo_change type ref to z2ui5_if_ajson,
|
lo_change TYPE REF TO z2ui5_if_ajson,
|
||||||
lo_insert_exp type ref to lcl_nodes_helper.
|
lo_insert_exp TYPE REF TO lcl_nodes_helper.
|
||||||
|
|
||||||
" Add empty array
|
" Add empty array
|
||||||
lv_json_a =
|
lv_json_a =
|
||||||
|
@ -356,17 +356,17 @@ class ltcl_json_utils implementation.
|
||||||
' "number": 123\n' &&
|
' "number": 123\n' &&
|
||||||
'}'.
|
'}'.
|
||||||
|
|
||||||
replace all occurrences of '\n' in lv_json_a with cl_abap_char_utilities=>newline.
|
REPLACE ALL OCCURRENCES OF '\n' IN lv_json_a WITH cl_abap_char_utilities=>newline.
|
||||||
replace all occurrences of '\n' in lv_json_b with cl_abap_char_utilities=>newline.
|
REPLACE ALL OCCURRENCES OF '\n' IN lv_json_b WITH cl_abap_char_utilities=>newline.
|
||||||
|
|
||||||
create object lo_util.
|
CREATE OBJECT lo_util.
|
||||||
|
|
||||||
" Empty arrays are ignored by default
|
" Empty arrays are ignored by default
|
||||||
lo_util->diff(
|
lo_util->diff(
|
||||||
exporting
|
EXPORTING
|
||||||
iv_json_a = lv_json_a
|
iv_json_a = lv_json_a
|
||||||
iv_json_b = lv_json_b
|
iv_json_b = lv_json_b
|
||||||
importing
|
IMPORTING
|
||||||
eo_insert = lo_insert
|
eo_insert = lo_insert
|
||||||
eo_delete = lo_delete
|
eo_delete = lo_delete
|
||||||
eo_change = lo_change ).
|
eo_change = lo_change ).
|
||||||
|
@ -385,16 +385,16 @@ class ltcl_json_utils implementation.
|
||||||
|
|
||||||
" Keep empty arrays
|
" Keep empty arrays
|
||||||
lo_util->diff(
|
lo_util->diff(
|
||||||
exporting
|
EXPORTING
|
||||||
iv_json_a = lv_json_a
|
iv_json_a = lv_json_a
|
||||||
iv_json_b = lv_json_b
|
iv_json_b = lv_json_b
|
||||||
iv_keep_empty_arrays = abap_true
|
iv_keep_empty_arrays = abap_true
|
||||||
importing
|
IMPORTING
|
||||||
eo_insert = lo_insert
|
eo_insert = lo_insert
|
||||||
eo_delete = lo_delete
|
eo_delete = lo_delete
|
||||||
eo_change = lo_change ).
|
eo_change = lo_change ).
|
||||||
|
|
||||||
create object lo_insert_exp.
|
CREATE OBJECT lo_insert_exp.
|
||||||
lo_insert_exp->add( ' | |object | |0|1' ).
|
lo_insert_exp->add( ' | |object | |0|1' ).
|
||||||
lo_insert_exp->add( '/ |names |array | |0|0' ).
|
lo_insert_exp->add( '/ |names |array | |0|0' ).
|
||||||
|
|
||||||
|
@ -410,16 +410,16 @@ class ltcl_json_utils implementation.
|
||||||
act = lines( lo_change->mt_json_tree )
|
act = lines( lo_change->mt_json_tree )
|
||||||
exp = 0 ).
|
exp = 0 ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method json_merge.
|
METHOD json_merge.
|
||||||
|
|
||||||
data:
|
DATA:
|
||||||
lv_json_a type string,
|
lv_json_a TYPE string,
|
||||||
lv_json_b type string,
|
lv_json_b TYPE string,
|
||||||
lo_util type ref to z2ui5_cl_ajson_utilities,
|
lo_util TYPE REF TO z2ui5_cl_ajson_utilities,
|
||||||
lo_merge type ref to z2ui5_if_ajson,
|
lo_merge TYPE REF TO z2ui5_if_ajson,
|
||||||
lo_merge_exp type ref to lcl_nodes_helper.
|
lo_merge_exp TYPE REF TO lcl_nodes_helper.
|
||||||
|
|
||||||
" Merge new value of b into a
|
" Merge new value of b into a
|
||||||
lv_json_a =
|
lv_json_a =
|
||||||
|
@ -441,10 +441,10 @@ class ltcl_json_utils implementation.
|
||||||
' "float": 123.45\n' &&
|
' "float": 123.45\n' &&
|
||||||
'}'.
|
'}'.
|
||||||
|
|
||||||
replace all occurrences of '\n' in lv_json_a with cl_abap_char_utilities=>newline.
|
REPLACE ALL OCCURRENCES OF '\n' IN lv_json_a WITH cl_abap_char_utilities=>newline.
|
||||||
replace all occurrences of '\n' in lv_json_b with cl_abap_char_utilities=>newline.
|
REPLACE ALL OCCURRENCES OF '\n' IN lv_json_b WITH cl_abap_char_utilities=>newline.
|
||||||
|
|
||||||
create object lo_merge_exp.
|
CREATE OBJECT lo_merge_exp.
|
||||||
lo_merge_exp->add( ' | |object | |0|3' ).
|
lo_merge_exp->add( ' | |object | |0|3' ).
|
||||||
lo_merge_exp->add( '/ |float |num |123.45 |0|0' ).
|
lo_merge_exp->add( '/ |float |num |123.45 |0|0' ).
|
||||||
lo_merge_exp->add( '/ |number |num |123 |0|0' ).
|
lo_merge_exp->add( '/ |number |num |123 |0|0' ).
|
||||||
|
@ -453,7 +453,7 @@ class ltcl_json_utils implementation.
|
||||||
lo_merge_exp->add( '/string/ |2 |str |c |2|0' ).
|
lo_merge_exp->add( '/string/ |2 |str |c |2|0' ).
|
||||||
lo_merge_exp->add( '/string/ |3 |str |b |3|0' ).
|
lo_merge_exp->add( '/string/ |3 |str |b |3|0' ).
|
||||||
|
|
||||||
create object lo_util.
|
CREATE OBJECT lo_util.
|
||||||
|
|
||||||
lo_merge = lo_util->merge(
|
lo_merge = lo_util->merge(
|
||||||
iv_json_a = lv_json_a
|
iv_json_a = lv_json_a
|
||||||
|
@ -463,15 +463,15 @@ class ltcl_json_utils implementation.
|
||||||
act = lo_merge->mt_json_tree
|
act = lo_merge->mt_json_tree
|
||||||
exp = lo_merge_exp->mt_nodes ).
|
exp = lo_merge_exp->mt_nodes ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method json_sort.
|
METHOD json_sort.
|
||||||
|
|
||||||
data:
|
DATA:
|
||||||
lv_json type string,
|
lv_json TYPE string,
|
||||||
lo_util type ref to z2ui5_cl_ajson_utilities,
|
lo_util TYPE REF TO z2ui5_cl_ajson_utilities,
|
||||||
lv_sorted type string,
|
lv_sorted TYPE string,
|
||||||
lv_sorted_exp type string.
|
lv_sorted_exp TYPE string.
|
||||||
|
|
||||||
lv_json =
|
lv_json =
|
||||||
'{\n' &&
|
'{\n' &&
|
||||||
|
@ -485,7 +485,7 @@ class ltcl_json_utils implementation.
|
||||||
' "date": "2020-03-15"\n' &&
|
' "date": "2020-03-15"\n' &&
|
||||||
'}'.
|
'}'.
|
||||||
|
|
||||||
replace all occurrences of '\n' in lv_json with cl_abap_char_utilities=>newline.
|
REPLACE ALL OCCURRENCES OF '\n' IN lv_json WITH cl_abap_char_utilities=>newline.
|
||||||
|
|
||||||
lv_sorted_exp =
|
lv_sorted_exp =
|
||||||
'{\n' &&
|
'{\n' &&
|
||||||
|
@ -499,9 +499,9 @@ class ltcl_json_utils implementation.
|
||||||
' "true": true\n' &&
|
' "true": true\n' &&
|
||||||
'}'.
|
'}'.
|
||||||
|
|
||||||
replace all occurrences of '\n' in lv_sorted_exp with cl_abap_char_utilities=>newline.
|
REPLACE ALL OCCURRENCES OF '\n' IN lv_sorted_exp WITH cl_abap_char_utilities=>newline.
|
||||||
|
|
||||||
create object lo_util.
|
CREATE OBJECT lo_util.
|
||||||
|
|
||||||
lv_sorted = lo_util->sort( iv_json = lv_json ).
|
lv_sorted = lo_util->sort( iv_json = lv_json ).
|
||||||
|
|
||||||
|
@ -509,9 +509,9 @@ class ltcl_json_utils implementation.
|
||||||
act = lv_sorted
|
act = lv_sorted
|
||||||
exp = lv_sorted_exp ).
|
exp = lv_sorted_exp ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
method is_equal.
|
METHOD is_equal.
|
||||||
|
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
act = z2ui5_cl_ajson_utilities=>new( )->is_equal(
|
act = z2ui5_cl_ajson_utilities=>new( )->is_equal(
|
||||||
|
@ -543,6 +543,6 @@ class ltcl_json_utils implementation.
|
||||||
iv_json_b = '{"a":1,"b":2}' )
|
iv_json_b = '{"a":1,"b":2}' )
|
||||||
exp = abap_false ).
|
exp = abap_false ).
|
||||||
|
|
||||||
endmethod.
|
ENDMETHOD.
|
||||||
|
|
||||||
endclass.
|
ENDCLASS.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class Z2UI5_CX_AJSON_ERROR definition
|
class z2ui5_cx_ajson_error definition
|
||||||
public
|
public
|
||||||
inheriting from CX_STATIC_CHECK
|
inheriting from CX_STATIC_CHECK
|
||||||
final
|
final
|
||||||
|
@ -45,7 +45,7 @@ public section.
|
||||||
!IV_LOCATION type STRING optional
|
!IV_LOCATION type STRING optional
|
||||||
!IS_NODE type ANY optional
|
!IS_NODE type ANY optional
|
||||||
raising
|
raising
|
||||||
Z2UI5_CX_AJSON_ERROR .
|
z2ui5_cx_ajson_error .
|
||||||
methods SET_LOCATION
|
methods SET_LOCATION
|
||||||
importing
|
importing
|
||||||
!IV_LOCATION type STRING optional
|
!IV_LOCATION type STRING optional
|
||||||
|
@ -64,10 +64,10 @@ ENDCLASS.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
CLASS Z2UI5_CX_AJSON_ERROR IMPLEMENTATION.
|
CLASS z2ui5_cx_ajson_error IMPLEMENTATION.
|
||||||
|
|
||||||
|
|
||||||
method CONSTRUCTOR ##ADT_SUPPRESS_GENERATION.
|
method CONSTRUCTOR.
|
||||||
CALL METHOD SUPER->CONSTRUCTOR
|
CALL METHOD SUPER->CONSTRUCTOR
|
||||||
EXPORTING
|
EXPORTING
|
||||||
PREVIOUS = PREVIOUS
|
PREVIOUS = PREVIOUS
|
||||||
|
|
|
@ -20,7 +20,9 @@ class ltcl_error implementation.
|
||||||
data lx type ref to z2ui5_cx_ajson_error.
|
data lx type ref to z2ui5_cx_ajson_error.
|
||||||
data lv_msg type string.
|
data lv_msg type string.
|
||||||
|
|
||||||
lv_msg = repeat( val = 'a' occ = 50 ) && repeat( val = 'b' occ = 50 ) && '123'.
|
lv_msg = repeat( val = 'a'
|
||||||
|
occ = 50 ) && repeat( val = 'b'
|
||||||
|
occ = 50 ) && '123'.
|
||||||
|
|
||||||
try.
|
try.
|
||||||
z2ui5_cx_ajson_error=>raise( lv_msg ).
|
z2ui5_cx_ajson_error=>raise( lv_msg ).
|
||||||
|
@ -38,7 +40,8 @@ class ltcl_error implementation.
|
||||||
data lx type ref to z2ui5_cx_ajson_error.
|
data lx type ref to z2ui5_cx_ajson_error.
|
||||||
|
|
||||||
try.
|
try.
|
||||||
z2ui5_cx_ajson_error=>raise( iv_msg = 'a' iv_location = 'b' ).
|
z2ui5_cx_ajson_error=>raise( iv_msg = 'a'
|
||||||
|
iv_location = 'b' ).
|
||||||
cl_abap_unit_assert=>fail( ).
|
cl_abap_unit_assert=>fail( ).
|
||||||
catch z2ui5_cx_ajson_error into lx.
|
catch z2ui5_cx_ajson_error into lx.
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
@ -57,7 +60,8 @@ class ltcl_error implementation.
|
||||||
ls_node-name = 'y'.
|
ls_node-name = 'y'.
|
||||||
|
|
||||||
try.
|
try.
|
||||||
z2ui5_cx_ajson_error=>raise( iv_msg = 'a' is_node = ls_node ).
|
z2ui5_cx_ajson_error=>raise( iv_msg = 'a'
|
||||||
|
is_node = ls_node ).
|
||||||
cl_abap_unit_assert=>fail( ).
|
cl_abap_unit_assert=>fail( ).
|
||||||
catch z2ui5_cx_ajson_error into lx.
|
catch z2ui5_cx_ajson_error into lx.
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
@ -72,7 +76,8 @@ class ltcl_error implementation.
|
||||||
data lx type ref to z2ui5_cx_ajson_error.
|
data lx type ref to z2ui5_cx_ajson_error.
|
||||||
|
|
||||||
try.
|
try.
|
||||||
z2ui5_cx_ajson_error=>raise( iv_msg = 'a' iv_location = 'b' ).
|
z2ui5_cx_ajson_error=>raise( iv_msg = 'a'
|
||||||
|
iv_location = 'b' ).
|
||||||
cl_abap_unit_assert=>fail( ).
|
cl_abap_unit_assert=>fail( ).
|
||||||
catch z2ui5_cx_ajson_error into lx.
|
catch z2ui5_cx_ajson_error into lx.
|
||||||
cl_abap_unit_assert=>assert_equals(
|
cl_abap_unit_assert=>assert_equals(
|
||||||
|
|
|
@ -1,262 +1,262 @@
|
||||||
interface z2ui5_if_ajson
|
INTERFACE z2ui5_if_ajson
|
||||||
public.
|
PUBLIC.
|
||||||
|
|
||||||
constants version type string value 'v1.1.9'. "#EC NOTEXT
|
CONSTANTS version TYPE string VALUE 'v1.1.10'. "#EC NOTEXT
|
||||||
constants origin type string value 'https://github.com/sbcgua/ajson'. "#EC NOTEXT
|
CONSTANTS origin TYPE string VALUE 'https://github.com/sbcgua/ajson'. "#EC NOTEXT
|
||||||
constants license type string value 'MIT'. "#EC NOTEXT
|
CONSTANTS license TYPE string VALUE 'MIT'. "#EC NOTEXT
|
||||||
|
|
||||||
types:
|
TYPES:
|
||||||
begin of ty_opts,
|
BEGIN OF ty_opts,
|
||||||
read_only type abap_bool,
|
read_only TYPE abap_bool,
|
||||||
keep_item_order type abap_bool,
|
keep_item_order TYPE abap_bool,
|
||||||
format_datetime type abap_bool,
|
format_datetime TYPE abap_bool,
|
||||||
to_abap_corresponding_only type abap_bool,
|
to_abap_corresponding_only TYPE abap_bool,
|
||||||
end of ty_opts.
|
END OF ty_opts.
|
||||||
|
|
||||||
" DATA
|
" DATA
|
||||||
|
|
||||||
data mt_json_tree type z2ui5_if_ajson_types=>ty_nodes_ts read-only.
|
DATA mt_json_tree TYPE z2ui5_if_ajson_types=>ty_nodes_ts READ-ONLY.
|
||||||
|
|
||||||
" CLONING
|
" CLONING
|
||||||
|
|
||||||
methods clone
|
METHODS clone
|
||||||
returning
|
RETURNING
|
||||||
value(ri_json) type ref to z2ui5_if_ajson
|
VALUE(ri_json) TYPE REF TO z2ui5_if_ajson
|
||||||
raising
|
RAISING
|
||||||
z2UI5_cx_ajson_error.
|
z2ui5_cx_ajson_error.
|
||||||
methods filter
|
METHODS filter
|
||||||
importing
|
IMPORTING
|
||||||
ii_filter type ref to z2ui5_if_ajson_filter
|
ii_filter TYPE REF TO z2ui5_if_ajson_filter
|
||||||
returning
|
RETURNING
|
||||||
value(ri_json) type ref to z2ui5_if_ajson
|
VALUE(ri_json) TYPE REF TO z2ui5_if_ajson
|
||||||
raising
|
RAISING
|
||||||
z2UI5_cx_ajson_error.
|
z2ui5_cx_ajson_error.
|
||||||
methods map
|
METHODS map
|
||||||
importing
|
IMPORTING
|
||||||
ii_mapper type ref to z2ui5_if_ajson_mapping
|
ii_mapper TYPE REF TO z2ui5_if_ajson_mapping
|
||||||
returning
|
RETURNING
|
||||||
value(ri_json) type ref to z2ui5_if_ajson
|
VALUE(ri_json) TYPE REF TO z2ui5_if_ajson
|
||||||
raising
|
RAISING
|
||||||
z2UI5_cx_ajson_error.
|
z2ui5_cx_ajson_error.
|
||||||
|
|
||||||
" METHODS
|
" METHODS
|
||||||
|
|
||||||
methods freeze.
|
METHODS freeze.
|
||||||
methods keep_item_order
|
METHODS keep_item_order
|
||||||
returning
|
RETURNING
|
||||||
value(ri_json) type ref to z2ui5_if_ajson.
|
VALUE(ri_json) TYPE REF TO z2ui5_if_ajson.
|
||||||
methods format_datetime
|
METHODS format_datetime
|
||||||
importing
|
IMPORTING
|
||||||
iv_use_iso type abap_bool default abap_true
|
iv_use_iso TYPE abap_bool DEFAULT abap_true
|
||||||
returning
|
RETURNING
|
||||||
value(ri_json) type ref to z2ui5_if_ajson.
|
VALUE(ri_json) TYPE REF TO z2ui5_if_ajson.
|
||||||
methods to_abap_corresponding_only
|
METHODS to_abap_corresponding_only
|
||||||
importing
|
IMPORTING
|
||||||
iv_enable type abap_bool default abap_true
|
iv_enable TYPE abap_bool DEFAULT abap_true
|
||||||
returning
|
RETURNING
|
||||||
value(ri_json) type ref to z2ui5_if_ajson.
|
VALUE(ri_json) TYPE REF TO z2ui5_if_ajson.
|
||||||
methods opts
|
METHODS opts
|
||||||
returning
|
RETURNING
|
||||||
value(rs_opts) type ty_opts.
|
VALUE(rs_opts) TYPE ty_opts.
|
||||||
|
|
||||||
" METHODS ex.reader
|
" METHODS ex.reader
|
||||||
|
|
||||||
methods is_empty
|
METHODS is_empty
|
||||||
returning
|
RETURNING
|
||||||
value(rv_yes) type abap_bool.
|
VALUE(rv_yes) TYPE abap_bool.
|
||||||
|
|
||||||
methods exists
|
METHODS exists
|
||||||
importing
|
IMPORTING
|
||||||
iv_path type string
|
iv_path TYPE string
|
||||||
returning
|
RETURNING
|
||||||
value(rv_exists) type abap_bool.
|
VALUE(rv_exists) TYPE abap_bool.
|
||||||
|
|
||||||
methods members
|
METHODS members
|
||||||
importing
|
IMPORTING
|
||||||
iv_path type string
|
iv_path TYPE string
|
||||||
returning
|
RETURNING
|
||||||
value(rt_members) type string_table.
|
VALUE(rt_members) TYPE string_table.
|
||||||
|
|
||||||
methods get
|
METHODS get
|
||||||
importing
|
IMPORTING
|
||||||
iv_path type string
|
iv_path TYPE string
|
||||||
returning
|
RETURNING
|
||||||
value(rv_value) type string.
|
VALUE(rv_value) TYPE string.
|
||||||
|
|
||||||
methods get_node_type
|
METHODS get_node_type
|
||||||
importing
|
IMPORTING
|
||||||
iv_path type string
|
iv_path TYPE string
|
||||||
returning
|
RETURNING
|
||||||
value(rv_node_type) type z2ui5_if_ajson_types=>ty_node_type.
|
VALUE(rv_node_type) TYPE z2ui5_if_ajson_types=>ty_node_type.
|
||||||
|
|
||||||
methods get_boolean
|
METHODS get_boolean
|
||||||
importing
|
IMPORTING
|
||||||
iv_path type string
|
iv_path TYPE string
|
||||||
returning
|
RETURNING
|
||||||
value(rv_value) type abap_bool.
|
VALUE(rv_value) TYPE abap_bool.
|
||||||
|
|
||||||
methods get_integer
|
METHODS get_integer
|
||||||
importing
|
IMPORTING
|
||||||
iv_path type string
|
iv_path TYPE string
|
||||||
returning
|
RETURNING
|
||||||
value(rv_value) type i.
|
VALUE(rv_value) TYPE i.
|
||||||
|
|
||||||
methods get_number
|
METHODS get_number
|
||||||
importing
|
IMPORTING
|
||||||
iv_path type string
|
iv_path TYPE string
|
||||||
returning
|
RETURNING
|
||||||
value(rv_value) type f.
|
VALUE(rv_value) TYPE f.
|
||||||
|
|
||||||
methods get_date
|
METHODS get_date
|
||||||
importing
|
IMPORTING
|
||||||
iv_path type string
|
iv_path TYPE string
|
||||||
returning
|
RETURNING
|
||||||
value(rv_value) type d.
|
VALUE(rv_value) TYPE d.
|
||||||
|
|
||||||
methods get_timestamp
|
METHODS get_timestamp
|
||||||
importing
|
IMPORTING
|
||||||
iv_path type string
|
iv_path TYPE string
|
||||||
returning
|
RETURNING
|
||||||
value(rv_value) type timestamp.
|
VALUE(rv_value) TYPE timestamp.
|
||||||
|
|
||||||
methods get_string
|
METHODS get_string
|
||||||
importing
|
IMPORTING
|
||||||
iv_path type string
|
iv_path TYPE string
|
||||||
returning
|
RETURNING
|
||||||
value(rv_value) type string.
|
VALUE(rv_value) TYPE string.
|
||||||
|
|
||||||
methods slice
|
METHODS slice
|
||||||
importing
|
IMPORTING
|
||||||
iv_path type string
|
iv_path TYPE string
|
||||||
returning
|
RETURNING
|
||||||
value(ri_json) type ref to z2ui5_if_ajson.
|
VALUE(ri_json) TYPE REF TO z2ui5_if_ajson.
|
||||||
|
|
||||||
methods to_abap
|
METHODS to_abap
|
||||||
importing
|
IMPORTING
|
||||||
iv_corresponding type abap_bool default abap_false
|
iv_corresponding TYPE abap_bool DEFAULT abap_false
|
||||||
exporting
|
EXPORTING
|
||||||
ev_container type any
|
ev_container TYPE any
|
||||||
raising
|
RAISING
|
||||||
z2UI5_cx_ajson_error.
|
z2ui5_cx_ajson_error.
|
||||||
|
|
||||||
methods array_to_string_table
|
METHODS array_to_string_table
|
||||||
importing
|
IMPORTING
|
||||||
iv_path type string
|
iv_path TYPE string
|
||||||
returning
|
RETURNING
|
||||||
value(rt_string_table) type string_table
|
VALUE(rt_string_table) TYPE string_table
|
||||||
raising
|
RAISING
|
||||||
z2UI5_cx_ajson_error.
|
z2ui5_cx_ajson_error.
|
||||||
|
|
||||||
" METHODS ex.writer
|
" METHODS ex.writer
|
||||||
|
|
||||||
methods clear
|
METHODS clear
|
||||||
raising
|
RAISING
|
||||||
z2UI5_cx_ajson_error.
|
z2ui5_cx_ajson_error.
|
||||||
|
|
||||||
methods set
|
METHODS set
|
||||||
importing
|
IMPORTING
|
||||||
iv_path type string
|
iv_path TYPE string
|
||||||
iv_val type any
|
iv_val TYPE any
|
||||||
iv_ignore_empty type abap_bool default abap_true
|
iv_ignore_empty TYPE abap_bool DEFAULT abap_true
|
||||||
iv_node_type type z2ui5_if_ajson_types=>ty_node_type optional
|
iv_node_type TYPE z2ui5_if_ajson_types=>ty_node_type OPTIONAL
|
||||||
returning
|
RETURNING
|
||||||
value(ri_json) type ref to z2ui5_if_ajson
|
VALUE(ri_json) TYPE REF TO z2ui5_if_ajson
|
||||||
raising
|
RAISING
|
||||||
z2UI5_cx_ajson_error.
|
z2ui5_cx_ajson_error.
|
||||||
|
|
||||||
methods setx
|
METHODS setx
|
||||||
importing
|
IMPORTING
|
||||||
iv_param type string
|
iv_param TYPE string
|
||||||
returning
|
RETURNING
|
||||||
value(ri_json) type ref to z2ui5_if_ajson
|
VALUE(ri_json) TYPE REF TO z2ui5_if_ajson
|
||||||
raising
|
RAISING
|
||||||
z2UI5_cx_ajson_error.
|
z2ui5_cx_ajson_error.
|
||||||
|
|
||||||
methods set_boolean
|
METHODS set_boolean
|
||||||
importing
|
IMPORTING
|
||||||
iv_path type string
|
iv_path TYPE string
|
||||||
iv_val type any
|
iv_val TYPE any
|
||||||
returning
|
RETURNING
|
||||||
value(ri_json) type ref to z2ui5_if_ajson
|
VALUE(ri_json) TYPE REF TO z2ui5_if_ajson
|
||||||
raising
|
RAISING
|
||||||
z2UI5_cx_ajson_error.
|
z2ui5_cx_ajson_error.
|
||||||
|
|
||||||
methods set_string
|
METHODS set_string
|
||||||
importing
|
IMPORTING
|
||||||
iv_path type string
|
iv_path TYPE string
|
||||||
iv_val type clike
|
iv_val TYPE clike
|
||||||
returning
|
RETURNING
|
||||||
value(ri_json) type ref to z2ui5_if_ajson
|
VALUE(ri_json) TYPE REF TO z2ui5_if_ajson
|
||||||
raising
|
RAISING
|
||||||
z2UI5_cx_ajson_error.
|
z2ui5_cx_ajson_error.
|
||||||
|
|
||||||
methods set_integer
|
METHODS set_integer
|
||||||
importing
|
IMPORTING
|
||||||
iv_path type string
|
iv_path TYPE string
|
||||||
iv_val type i
|
iv_val TYPE i
|
||||||
returning
|
RETURNING
|
||||||
value(ri_json) type ref to z2ui5_if_ajson
|
VALUE(ri_json) TYPE REF TO z2ui5_if_ajson
|
||||||
raising
|
RAISING
|
||||||
z2UI5_cx_ajson_error.
|
z2ui5_cx_ajson_error.
|
||||||
|
|
||||||
methods set_date
|
METHODS set_date
|
||||||
importing
|
IMPORTING
|
||||||
iv_path type string
|
iv_path TYPE string
|
||||||
iv_val type d
|
iv_val TYPE d
|
||||||
returning
|
RETURNING
|
||||||
value(ri_json) type ref to z2ui5_if_ajson
|
VALUE(ri_json) TYPE REF TO z2ui5_if_ajson
|
||||||
raising
|
RAISING
|
||||||
z2UI5_cx_ajson_error.
|
z2ui5_cx_ajson_error.
|
||||||
|
|
||||||
methods set_timestamp
|
METHODS set_timestamp
|
||||||
importing
|
IMPORTING
|
||||||
iv_path type string
|
iv_path TYPE string
|
||||||
iv_val type timestamp
|
iv_val TYPE timestamp
|
||||||
returning
|
RETURNING
|
||||||
value(ri_json) type ref to z2ui5_if_ajson
|
VALUE(ri_json) TYPE REF TO z2ui5_if_ajson
|
||||||
raising
|
RAISING
|
||||||
z2UI5_cx_ajson_error.
|
z2ui5_cx_ajson_error.
|
||||||
|
|
||||||
methods set_null
|
METHODS set_null
|
||||||
importing
|
IMPORTING
|
||||||
iv_path type string
|
iv_path TYPE string
|
||||||
returning
|
RETURNING
|
||||||
value(ri_json) type ref to z2ui5_if_ajson
|
VALUE(ri_json) TYPE REF TO z2ui5_if_ajson
|
||||||
raising
|
RAISING
|
||||||
z2UI5_cx_ajson_error.
|
z2ui5_cx_ajson_error.
|
||||||
|
|
||||||
methods delete
|
METHODS delete
|
||||||
importing
|
IMPORTING
|
||||||
iv_path type string
|
iv_path TYPE string
|
||||||
returning
|
RETURNING
|
||||||
value(ri_json) type ref to z2ui5_if_ajson
|
VALUE(ri_json) TYPE REF TO z2ui5_if_ajson
|
||||||
raising
|
RAISING
|
||||||
z2UI5_cx_ajson_error.
|
z2ui5_cx_ajson_error.
|
||||||
|
|
||||||
methods touch_array
|
METHODS touch_array
|
||||||
importing
|
IMPORTING
|
||||||
iv_path type string
|
iv_path TYPE string
|
||||||
iv_clear type abap_bool default abap_false
|
iv_clear TYPE abap_bool DEFAULT abap_false
|
||||||
returning
|
RETURNING
|
||||||
value(ri_json) type ref to z2ui5_if_ajson
|
VALUE(ri_json) TYPE REF TO z2ui5_if_ajson
|
||||||
raising
|
RAISING
|
||||||
z2UI5_cx_ajson_error.
|
z2ui5_cx_ajson_error.
|
||||||
|
|
||||||
methods push
|
METHODS push
|
||||||
importing
|
IMPORTING
|
||||||
iv_path type string
|
iv_path TYPE string
|
||||||
iv_val type any
|
iv_val TYPE any
|
||||||
returning
|
RETURNING
|
||||||
value(ri_json) type ref to z2ui5_if_ajson
|
VALUE(ri_json) TYPE REF TO z2ui5_if_ajson
|
||||||
raising
|
RAISING
|
||||||
z2UI5_cx_ajson_error.
|
z2ui5_cx_ajson_error.
|
||||||
|
|
||||||
methods stringify
|
METHODS stringify
|
||||||
importing
|
IMPORTING
|
||||||
iv_indent type i default 0
|
iv_indent TYPE i DEFAULT 0
|
||||||
returning
|
RETURNING
|
||||||
value(rv_json) type string
|
VALUE(rv_json) TYPE string
|
||||||
raising
|
RAISING
|
||||||
z2UI5_cx_ajson_error.
|
z2ui5_cx_ajson_error.
|
||||||
|
|
||||||
endinterface.
|
ENDINTERFACE.
|
||||||
|
|
|
@ -1,23 +1,23 @@
|
||||||
interface z2ui5_if_ajson_filter
|
INTERFACE z2ui5_if_ajson_filter
|
||||||
public.
|
PUBLIC.
|
||||||
|
|
||||||
types ty_filter_tab TYPE STANDARD TABLE OF ref to z2ui5_if_ajson_filter with key table_line.
|
TYPES ty_filter_tab TYPE STANDARD TABLE OF REF TO z2ui5_if_ajson_filter WITH KEY table_line.
|
||||||
types ty_visit_type type i.
|
TYPES ty_visit_type TYPE i.
|
||||||
|
|
||||||
constants:
|
CONSTANTS:
|
||||||
begin of visit_type,
|
BEGIN OF visit_type,
|
||||||
value type ty_visit_type value 0,
|
value TYPE ty_visit_type VALUE 0,
|
||||||
open type ty_visit_type value 1,
|
open TYPE ty_visit_type VALUE 1,
|
||||||
close type ty_visit_type value 2,
|
close TYPE ty_visit_type VALUE 2,
|
||||||
end of visit_type.
|
END OF visit_type.
|
||||||
|
|
||||||
methods keep_node
|
METHODS keep_node
|
||||||
importing
|
IMPORTING
|
||||||
is_node type z2ui5_if_ajson_types=>ty_node
|
is_node TYPE z2ui5_if_ajson_types=>ty_node
|
||||||
iv_visit type ty_visit_type default visit_type-value
|
iv_visit TYPE ty_visit_type DEFAULT visit_type-value
|
||||||
returning
|
RETURNING
|
||||||
value(rv_keep) type abap_bool
|
VALUE(rv_keep) TYPE abap_bool
|
||||||
raising
|
RAISING
|
||||||
z2UI5_cx_ajson_error.
|
z2ui5_cx_ajson_error.
|
||||||
|
|
||||||
endinterface.
|
ENDINTERFACE.
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
INTERFACE z2ui5_if_ajson_mapping
|
INTERFACE z2ui5_if_ajson_mapping
|
||||||
PUBLIC.
|
PUBLIC.
|
||||||
|
|
||||||
INTERFACES if_serializable_object.
|
|
||||||
|
|
||||||
TYPES:
|
TYPES:
|
||||||
BEGIN OF ty_mapping_field, " deprecated, will be removed
|
BEGIN OF ty_mapping_field, " deprecated, will be removed
|
||||||
abap TYPE string,
|
abap TYPE string,
|
||||||
|
@ -15,7 +13,7 @@ INTERFACE z2ui5_if_ajson_mapping
|
||||||
TYPES:
|
TYPES:
|
||||||
BEGIN OF ty_rename,
|
BEGIN OF ty_rename,
|
||||||
from TYPE string,
|
from TYPE string,
|
||||||
to TYPE string,
|
to TYPE string,
|
||||||
END OF ty_rename,
|
END OF ty_rename,
|
||||||
tty_rename_map TYPE STANDARD TABLE OF ty_rename
|
tty_rename_map TYPE STANDARD TABLE OF ty_rename
|
||||||
WITH UNIQUE SORTED KEY by_name COMPONENTS from.
|
WITH UNIQUE SORTED KEY by_name COMPONENTS from.
|
||||||
|
|
|
@ -1,41 +1,41 @@
|
||||||
interface z2ui5_if_ajson_types
|
INTERFACE z2ui5_if_ajson_types
|
||||||
public.
|
PUBLIC.
|
||||||
|
|
||||||
types:
|
TYPES:
|
||||||
ty_node_type type string.
|
ty_node_type TYPE string.
|
||||||
|
|
||||||
constants:
|
CONSTANTS:
|
||||||
begin of node_type,
|
BEGIN OF node_type,
|
||||||
boolean type ty_node_type value 'bool',
|
boolean TYPE ty_node_type VALUE 'bool',
|
||||||
string type ty_node_type value 'str',
|
string TYPE ty_node_type VALUE 'str',
|
||||||
number type ty_node_type value 'num',
|
number TYPE ty_node_type VALUE 'num',
|
||||||
null type ty_node_type value 'null',
|
null TYPE ty_node_type VALUE 'null',
|
||||||
array type ty_node_type value 'array',
|
array TYPE ty_node_type VALUE 'array',
|
||||||
object type ty_node_type value 'object',
|
object TYPE ty_node_type VALUE 'object',
|
||||||
end of node_type.
|
END OF node_type.
|
||||||
|
|
||||||
types:
|
TYPES:
|
||||||
begin of ty_node,
|
BEGIN OF ty_node,
|
||||||
path type string,
|
path TYPE string,
|
||||||
name type string,
|
name TYPE string,
|
||||||
type type ty_node_type,
|
type TYPE ty_node_type,
|
||||||
value type string,
|
value TYPE string,
|
||||||
index type i,
|
index TYPE i,
|
||||||
order type i,
|
order TYPE i,
|
||||||
children type i,
|
children TYPE i,
|
||||||
end of ty_node.
|
END OF ty_node.
|
||||||
types:
|
TYPES:
|
||||||
ty_nodes_tt TYPE STANDARD TABLE OF ty_node with key path name.
|
ty_nodes_tt TYPE STANDARD TABLE OF ty_node WITH KEY path name.
|
||||||
types:
|
TYPES:
|
||||||
ty_nodes_ts type sorted table of ty_node
|
ty_nodes_ts TYPE SORTED TABLE OF ty_node
|
||||||
with unique key path name
|
WITH UNIQUE KEY path name
|
||||||
with non-unique sorted key array_index components path index
|
WITH NON-UNIQUE SORTED KEY array_index COMPONENTS path index
|
||||||
with non-unique sorted key item_order components path order.
|
WITH NON-UNIQUE SORTED KEY item_order COMPONENTS path order.
|
||||||
|
|
||||||
types:
|
TYPES:
|
||||||
begin of ty_path_name,
|
BEGIN OF ty_path_name,
|
||||||
path type string,
|
path TYPE string,
|
||||||
name type string,
|
name TYPE string,
|
||||||
end of ty_path_name.
|
END OF ty_path_name.
|
||||||
|
|
||||||
endinterface.
|
ENDINTERFACE.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user