Skip to content

Automatic Update #20

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

Merged
merged 1 commit into from
Feb 25, 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
2 changes: 2 additions & 0 deletions src/z2ui5_cl_ajson.clas.abap
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,8 @@ CLASS z2ui5_cl_ajson IMPLEMENTATION.
DATA lv_path_pattern TYPE string.

CREATE OBJECT lo_section.
lo_section->mi_custom_mapping = mi_custom_mapping.

lv_normalized_path = lcl_utils=>normalize_path( iv_path ).
lv_path_len = strlen( lv_normalized_path ).
ls_path_parts = lcl_utils=>split_path( lv_normalized_path ).
Expand Down
28 changes: 28 additions & 0 deletions src/z2ui5_cl_ajson_mapping.clas.testclasses.abap
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ CLASS ltcl_fields DEFINITION FINAL FOR TESTING
to_json_without_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_with_slice 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.


Expand Down Expand Up @@ -403,6 +404,33 @@ CLASS ltcl_fields IMPLEMENTATION.

ENDMETHOD.

METHOD to_abap_with_slice.

DATA: BEGIN OF ls_act,
y TYPE i,
END OF ls_act.

DATA lo_cut TYPE REF TO z2ui5_if_ajson.
DATA lt_mapping_fields TYPE z2ui5_if_ajson_mapping=>ty_mapping_fields.
DATA ls_mapping_field LIKE LINE OF lt_mapping_fields.

CLEAR ls_mapping_field.
ls_mapping_field-abap = 'Y'.
ls_mapping_field-json = 'c'.
INSERT ls_mapping_field INTO TABLE lt_mapping_fields.

lo_cut = z2ui5_cl_ajson=>parse( iv_json = '{"a":1,"b":{"c":2},"d":{"e":3}}'
ii_custom_mapping = z2ui5_cl_ajson_mapping=>create_field_mapping( lt_mapping_fields )
)->slice( `/b` ).

lo_cut->to_abap( IMPORTING ev_container = ls_act ).

cl_abap_unit_assert=>assert_equals(
act = ls_act-y
exp = 2 ).

ENDMETHOD.


METHOD to_json_without_path.

Expand Down
2 changes: 1 addition & 1 deletion src/z2ui5_if_ajson.intf.abap
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
INTERFACE z2ui5_if_ajson
PUBLIC.

CONSTANTS version TYPE string VALUE 'v1.1.10'. "#EC NOTEXT
CONSTANTS version TYPE string VALUE 'v1.1.11'. "#EC NOTEXT
CONSTANTS origin TYPE string VALUE 'https://github.com/sbcgua/ajson'. "#EC NOTEXT
CONSTANTS license TYPE string VALUE 'MIT'. "#EC NOTEXT

Expand Down