From e8da0b93a0a7811b7504934bc0883acb05722a19 Mon Sep 17 00:00:00 2001 From: Lars Hvam Date: Fri, 10 Nov 2023 15:59:01 +0100 Subject: [PATCH 1/3] json, add testcase --- src/json/#ui2#cl_json.clas.testclasses.abap | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/json/#ui2#cl_json.clas.testclasses.abap b/src/json/#ui2#cl_json.clas.testclasses.abap index f42d2a56..2e4cff64 100644 --- a/src/json/#ui2#cl_json.clas.testclasses.abap +++ b/src/json/#ui2#cl_json.clas.testclasses.abap @@ -30,6 +30,7 @@ CLASS ltcl_deserialize DEFINITION FOR TESTING RISK LEVEL HARMLESS DURATION SHORT METHODS more_array FOR TESTING RAISING cx_static_check. METHODS deserialize_float_to_ref FOR TESTING RAISING cx_static_check. METHODS deserialize_packed_empty FOR TESTING RAISING cx_static_check. + METHODS refs_something FOR TESTING RAISING cx_static_check. ENDCLASS. @@ -593,6 +594,21 @@ CLASS ltcl_deserialize IMPLEMENTATION. ENDMETHOD. + METHOD refs_something. + + DATA lv_json TYPE string. + DATA lr_data TYPE REF TO data. + + lv_json = `{"oScroll": []}`. + + /ui2/cl_json=>deserialize( + EXPORTING + json = lv_json + CHANGING + data = lr_data ). + + ENDMETHOD. + ENDCLASS. ***************************************************************************************** From 015cb98a960f95916c390c6463810468a900790a Mon Sep 17 00:00:00 2001 From: Lars Hvam Date: Fri, 10 Nov 2023 16:07:05 +0100 Subject: [PATCH 2/3] update testcase --- src/json/#ui2#cl_json.clas.testclasses.abap | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/json/#ui2#cl_json.clas.testclasses.abap b/src/json/#ui2#cl_json.clas.testclasses.abap index 2e4cff64..c70df0d9 100644 --- a/src/json/#ui2#cl_json.clas.testclasses.abap +++ b/src/json/#ui2#cl_json.clas.testclasses.abap @@ -599,6 +599,9 @@ CLASS ltcl_deserialize IMPLEMENTATION. DATA lv_json TYPE string. DATA lr_data TYPE REF TO data. + FIELD-SYMBOLS TYPE any. + + lv_json = `{"oScroll": []}`. /ui2/cl_json=>deserialize( @@ -607,6 +610,12 @@ CLASS ltcl_deserialize IMPLEMENTATION. CHANGING data = lr_data ). + cl_abap_unit_assert=>assert_not_initial( lr_data ). + ASSIGN lr_data->* TO . + cl_abap_unit_assert=>assert_subrc( ). + ASSIGN COMPONENT 'OSCROLL' OF STRUCTURE TO . + cl_abap_unit_assert=>assert_subrc( ). + ENDMETHOD. ENDCLASS. From f525ba69cb26fd8071b2d212f06a709045d035b6 Mon Sep 17 00:00:00 2001 From: Lars Hvam Date: Fri, 10 Nov 2023 16:13:14 +0100 Subject: [PATCH 3/3] bugfix --- src/json/#ui2#cl_json.clas.abap | 2 +- src/json/#ui2#cl_json.clas.testclasses.abap | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/json/#ui2#cl_json.clas.abap b/src/json/#ui2#cl_json.clas.abap index 3bc504ae..76f95222 100644 --- a/src/json/#ui2#cl_json.clas.abap +++ b/src/json/#ui2#cl_json.clas.abap @@ -309,7 +309,7 @@ CLASS /ui2/cl_json IMPLEMENTATION. ENDLOOP. lo_struct = cl_abap_structdescr=>create( lt_components ). CREATE DATA data TYPE HANDLE lo_struct. - ELSEIF lines( lt_members ) > 0 AND lv_type = 'array'. + ELSEIF lv_type = 'array'. lo_table = cl_abap_tabledescr=>create( cl_abap_refdescr=>get_ref_to_data( ) ). CREATE DATA data TYPE HANDLE lo_table. ELSE. diff --git a/src/json/#ui2#cl_json.clas.testclasses.abap b/src/json/#ui2#cl_json.clas.testclasses.abap index c70df0d9..cab9794e 100644 --- a/src/json/#ui2#cl_json.clas.testclasses.abap +++ b/src/json/#ui2#cl_json.clas.testclasses.abap @@ -600,6 +600,7 @@ CLASS ltcl_deserialize IMPLEMENTATION. DATA lr_data TYPE REF TO data. FIELD-SYMBOLS TYPE any. + FIELD-SYMBOLS TYPE ANY TABLE. lv_json = `{"oScroll": []}`. @@ -615,6 +616,10 @@ CLASS ltcl_deserialize IMPLEMENTATION. cl_abap_unit_assert=>assert_subrc( ). ASSIGN COMPONENT 'OSCROLL' OF STRUCTURE TO . cl_abap_unit_assert=>assert_subrc( ). + ASSIGN ->* TO
. + cl_abap_unit_assert=>assert_equals( + exp = 0 + act = lines(
) ). ENDMETHOD.