2020 Nov 09 5:43 PM
Hey guys I was reading a lot of this topic and I have a problem.
I have a this Json that contains children:

I have maped this json to get information from ABAP but I am not sure if I maped correctly because I get all information excepted children.

As I understand I need to have a node Respuesta and inside of this a node called Archivos:

As you can see I have this strucutre but I have not data.
Could anyone can told me If I am doing something worng?
My code below:
REPORT z_test.
TYPES: BEGIN OF ty_archivos, "ANTES DATA:
idArchivo TYPE string,
URLAzureBlob TYPE string,
END OF ty_archivos.
DATA: BEGIN OF Archivos OCCURS 0, "itab with header line
Archivos TYPE ty_archivos,
END OF Archivos.
TYPES: BEGIN OF ty_archivo.
INCLUDE STRUCTURE Archivos.
TYPES END OF ty_archivo.
DATA: v_json TYPE string.
CLASS lcl_data DEFINITION FINAL.
PUBLIC SECTION.
DATA:
IsOnline TYPE string,
IsActionPermitted TYPE string,
IsExists TYPE string,
IsOk TYPE string,
MensajeID TYPE string,
Mensaje TYPE string,
TipoUsuario TYPE string,
UserName TYPE string,
Password TYPE string,
ID TYPE string,
Fecha TYPE string,
URL TYPE string,
NoFilas TYPE string,
Permiso TYPE string,
dsRespuesta TYPE STANDARD TABLE OF ty_archivo,
Nota TYPE string.
ENDCLASS.
DATA: lo_class TYPE REF TO lcl_data.
CREATE OBJECT lo_class.
*
**
CONCATENATE '{"IsOnline": true,"IsActionPermitted": false,"IsExists": false,"IsOk": false,'
'"MensajeID": 0,"Mensaje": "","TipoUsuario": null,"UserName": "","Password": null,"ID": "cf9b899f-a48b-4071-8ab1-96788e321b68",'
'"Fecha": "2020-11-06T22:55:09.8449458+00:00","URL": "","NoFilas": 1,"Permiso": "SI","dsRespuesta": {"Archivos": [{"idArchivo": "cf9b899f-a48b-4071-8ab1-96788e321b68",'
'"URLAzureBlob": "API\\Files\\SaveTemp\\4551cf9b899f-a48b-4071-8ab1-96788e321b68.xml"}]},"Nota": null}'
INTO v_json.
/ui2/cl_json=>deserialize( EXPORTING json = v_json CHANGING data = lo_class ).
2020 Nov 10 1:24 PM
Hi Luis Roberto Franco,
First of all you don't define structure, dsRespuesta is an structure not a table. This structure include a table. I coded for you. You can follow your way but I used se11 to define structures and table types. I am sharing with you step by step( please take attention to underscores _ these are for camel case notation, every letter that followed after underscore will be upper case letter.
Step 1 : Main structure;

Step2 : Zds_Respuesta structure definition

Step3 : Archivos table type definiton

Step4 : Archivos structure definiton

Step 5 : Codes which are include camel case and array definitions.
*&---------------------------------------------------------------------*
*& Report ZTESTTTT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ztestttt.
CLASS lcl_serialize DEFINITION.
PUBLIC SECTION.
METHODS main.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS lcl_serialize IMPLEMENTATION.
METHOD main.
DATA: lv_body TYPE string.
DATA: ls_json TYPE zjson.
DATA: ls_ARCHIVOS TYPE zarchivos_s.
ls_json-_is_online = 'true'.
ls_json-_is_actionpermitted = 'false'.
ls_json-_is_exists = 'false'.
ls_json-_is_ok = 'false'.
ls_json-_mensaje_id = '0'.
ls_json-_mensaje = ''.
ls_json-_tipo_usuario = 'null'.
ls_json-_user_name = ''.
ls_json-_password = ''.
ls_json-_id = 'cf9b899f-a48b-4071-8ab1-96788e321b68'.
ls_json-_fecha = '2020-11-06T22:55:09.8449458+00:00'.
ls_json-_url = ''.
ls_json-_no_filas = '1'.
ls_json-_permiso = 'SI'.
ls_ARCHIVOS-_id_archivo = 'cf9b899f-a48b-4071-8ab1-96788e321b68'.
ls_ARCHIVOS-_url_azure_blob = 'API\\Files\\SaveTemp\\4551cf9b899f-a48b-4071-8ab1-96788e321b68.xml'.
APPEND ls_ARCHIVOS TO ls_json-ds_respuesta-_archivos.
CLEAR: ls_ARCHIVOS.
ls_json-_nota = 'null'.
lv_body = /ui2/cl_json=>serialize( data = ls_json
pretty_name = /ui2/cl_json=>pretty_mode-camel_case
assoc_arrays = abap_true
assoc_arrays_opt = abap_true ).
cl_demo_output=>write_json( lv_body ).
cl_demo_output=>display( ).
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA(lo_class) = NEW lcl_serialize( ).
lo_class->main( ).Step6: Result

Best Regards.
Hey guys I was reading a lot of this topic and I have a problem.
I have a this Json that contains children:

I have maped this json to get information from ABAP but I am not sure if I maped correctly because I get all information excepted children.

As I understand I need to have a node Respuesta and inside of this a node called Archivos:

As you can see I have this strucutre but I have not data.
Could anyone can told me If I am doing something worng?
My code below:
REPORT z_test.
TYPES: BEGIN OF ty_archivos, "ANTES DATA:
idArchivo TYPE string,
URLAzureBlob TYPE string,
END OF ty_archivos.
DATA: BEGIN OF Archivos OCCURS 0, "itab with header line
Archivos TYPE ty_archivos,
END OF Archivos.
TYPES: BEGIN OF ty_archivo.
INCLUDE STRUCTURE Archivos.
TYPES END OF ty_archivo.
DATA: v_json TYPE string.
CLASS lcl_data DEFINITION FINAL.
PUBLIC SECTION.
DATA:
IsOnline TYPE string,
IsActionPermitted TYPE string,
IsExists TYPE string,
IsOk TYPE string,
MensajeID TYPE string,
Mensaje TYPE string,
TipoUsuario TYPE string,
UserName TYPE string,
Password TYPE string,
ID TYPE string,
Fecha TYPE string,
URL TYPE string,
NoFilas TYPE string,
Permiso TYPE string,
dsRespuesta TYPE STANDARD TABLE OF ty_archivo,
Nota TYPE string.
ENDCLASS.
DATA: lo_class TYPE REF TO lcl_data.
CREATE OBJECT lo_class.
*
**
CONCATENATE '{"IsOnline": true,"IsActionPermitted": false,"IsExists": false,"IsOk": false,'
'"MensajeID": 0,"Mensaje": "","TipoUsuario": null,"UserName": "","Password": null,"ID": "cf9b899f-a48b-4071-8ab1-96788e321b68",'
'"Fecha": "2020-11-06T22:55:09.8449458+00:00","URL": "","NoFilas": 1,"Permiso": "SI","dsRespuesta": {"Archivos": [{"idArchivo": "cf9b899f-a48b-4071-8ab1-96788e321b68",'
'"URLAzureBlob": "API\\Files\\SaveTemp\\4551cf9b899f-a48b-4071-8ab1-96788e321b68.xml"}]},"Nota": null}'
INTO v_json.
/ui2/cl_json=>deserialize( EXPORTING json = v_json CHANGING data = lo_class ).
2020 Nov 10 1:24 PM
Hi Luis Roberto Franco,
First of all you don't define structure, dsRespuesta is an structure not a table. This structure include a table. I coded for you. You can follow your way but I used se11 to define structures and table types. I am sharing with you step by step( please take attention to underscores _ these are for camel case notation, every letter that followed after underscore will be upper case letter.
Step 1 : Main structure;

Step2 : Zds_Respuesta structure definition

Step3 : Archivos table type definiton

Step4 : Archivos structure definiton

Step 5 : Codes which are include camel case and array definitions.
*&---------------------------------------------------------------------*
*& Report ZTESTTTT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT ztestttt.
CLASS lcl_serialize DEFINITION.
PUBLIC SECTION.
METHODS main.
PROTECTED SECTION.
PRIVATE SECTION.
ENDCLASS.
CLASS lcl_serialize IMPLEMENTATION.
METHOD main.
DATA: lv_body TYPE string.
DATA: ls_json TYPE zjson.
DATA: ls_ARCHIVOS TYPE zarchivos_s.
ls_json-_is_online = 'true'.
ls_json-_is_actionpermitted = 'false'.
ls_json-_is_exists = 'false'.
ls_json-_is_ok = 'false'.
ls_json-_mensaje_id = '0'.
ls_json-_mensaje = ''.
ls_json-_tipo_usuario = 'null'.
ls_json-_user_name = ''.
ls_json-_password = ''.
ls_json-_id = 'cf9b899f-a48b-4071-8ab1-96788e321b68'.
ls_json-_fecha = '2020-11-06T22:55:09.8449458+00:00'.
ls_json-_url = ''.
ls_json-_no_filas = '1'.
ls_json-_permiso = 'SI'.
ls_ARCHIVOS-_id_archivo = 'cf9b899f-a48b-4071-8ab1-96788e321b68'.
ls_ARCHIVOS-_url_azure_blob = 'API\\Files\\SaveTemp\\4551cf9b899f-a48b-4071-8ab1-96788e321b68.xml'.
APPEND ls_ARCHIVOS TO ls_json-ds_respuesta-_archivos.
CLEAR: ls_ARCHIVOS.
ls_json-_nota = 'null'.
lv_body = /ui2/cl_json=>serialize( data = ls_json
pretty_name = /ui2/cl_json=>pretty_mode-camel_case
assoc_arrays = abap_true
assoc_arrays_opt = abap_true ).
cl_demo_output=>write_json( lv_body ).
cl_demo_output=>display( ).
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
DATA(lo_class) = NEW lcl_serialize( ).
lo_class->main( ).Step6: Result

Best Regards.
2020 Nov 19 9:07 PM
many thanks for take the time to programing and create these objects for explain me, you dont have idea that how you have help me.
Again thanks!
2020 Nov 13 4:25 PM
Hi Luis Roberto Franco,
If you think above answer is correct please upvote it.
Best Regards.