Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix create_path_filter with mixed case nodes #192

Merged
merged 2 commits into from
Feb 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/libs/zcl_ajson_filter_lib.clas.locals_imp.abap
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class lcl_paths_filter implementation.
endif.

loop at it_skip_paths into lv_s.
lv_s = to_lower( lv_s ).
lv_s = condense( lv_s ).
append lv_s to lt_tab.
endloop.

Expand All @@ -83,7 +83,7 @@ class lcl_paths_filter implementation.
delete lt_tab index sy-tabix.
continue.
endif.
<s> = condense( to_lower( <s> ) ).
<s> = condense( <s> ).
endloop.
endif.

Expand Down
33 changes: 33 additions & 0 deletions src/libs/zcl_ajson_filter_lib.clas.testclasses.abap
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ class ltcl_filters_test definition final
methods path_filter_w_patterns for testing raising zcx_ajson_error.
methods path_filter_deep for testing raising zcx_ajson_error.
methods and_filter for testing raising zcx_ajson_error.
methods mixed_case_filter for testing raising zcx_ajson_error.
endclass.


Expand Down Expand Up @@ -227,4 +228,36 @@ class ltcl_filters_test implementation.

endmethod.

method mixed_case_filter.

data li_json type ref to zif_ajson.
data li_json_filtered type ref to zif_ajson.

li_json = zcl_ajson=>create_empty( ).
li_json->set(
iv_path = '/a'
iv_val = '1' ).
li_json->set(
iv_path = '/bB'
iv_val = '2' ).
li_json->set(
iv_path = '/CC'
iv_val = '3' ).
li_json->set(
iv_path = '/cc'
iv_val = '4' ).
li_json->set(
iv_path = '/d'
iv_val = 5 ).

li_json_filtered = zcl_ajson=>create_from(
ii_source_json = li_json
ii_filter = zcl_ajson_filter_lib=>create_path_filter( iv_skip_paths = '/bB,/CC' ) ).

cl_abap_unit_assert=>assert_equals(
act = li_json_filtered->stringify( )
exp = '{"a":"1","cc":"4","d":5}' ).

endmethod.

endclass.
Loading