2020 Mar 14 12:48 AM
Hello i'm triying to use /UI2/CL_JSON class => SERIALIZE() i pass my json and create my structure but my structured is not filled.
TYPES: BEGIN OF ty_a,
BUKRS(25),
VSTEL(25),
VKORG(25),
FECHA(25),
CANAL(25),
SECTOR(25),
SOLIC(25),
END OF ty_a,
BEGIN OF ty_b,
pedido(25),
werks(25),
posiciones TYPE zborrar_posiciones,"TYPE TABLE of a structure with two fields: matnr and ctdad
suppl_plnt(25),
lotno(25),
bokno(25),
kschl(25),
trans(25),
printer(25),
msg(25),
END OF ty_b,
BEGIN OF ty_x,
accion(10),
input TYPE ty_a,
data_cont TYPE ty_b,
END OF ty_x.
DATA: ls_info TYPE ty_x.
* deserialize JSON string json into internal table lt_flight doing camelCase to ABAP like field name mapping
DATA: str1 TYPE string VALUE '"accion":"CREA_LA","input":{"BUKRS":"","VSTEL":"","VKORG":"","FECHA":"","CANAL":"","SECTOR":"","SOLIC":""},"data_cont":{"pedido":"219135968","werks":"1100"'.
DATA: str2 TYPE string VALUE ',"suppl_plnt":"","lotno":"","bokno":"","kschl":"","trans":"","printer":"","msg":""}'.
DATA: final TYPE string.
CONCATENATE str1 str2 INTO final.
/ui2/cl_json=>deserialize( EXPORTING json = final pretty_name = /ui2/cl_json=>pretty_mode-camel_case CHANGING data = ls_info ).
The last line it's executed but is not filling my structure, what am i doing wrong ???
2020 Mar 14 7:03 AM
naotoxxx As your JSON string is not a valid JSON the deserialization does nothing. Why your string is not a valid JSON string? Because the opening and closing curly brackets are missing. In the following formatted example of your string, the first and last line I added.
{
"accion": "CREA_LA",
"input": {
"BUKRS": "",
"VSTEL": "",
"VKORG": "",
"FECHA": "",
"CANAL": "",
"SECTOR": "",
"SOLIC": ""
},
"data_cont": {
"pedido": "219135968",
"werks": "1100",
"suppl_plnt": "",
"lotno": "",
"bokno": "",
"kschl": "",
"trans": "",
"printer": "",
"msg": ""
}
}
naotoxxx As your JSON string is not a valid JSON the deserialization does nothing. Why your string is not a valid JSON string? Because the opening and closing curly brackets are missing. In the following formatted example of your string, the first and last line I added.
{
"accion": "CREA_LA",
"input": {
"BUKRS": "",
"VSTEL": "",
"VKORG": "",
"FECHA": "",
"CANAL": "",
"SECTOR": "",
"SOLIC": ""
},
"data_cont": {
"pedido": "219135968",
"werks": "1100",
"suppl_plnt": "",
"lotno": "",
"bokno": "",
"kschl": "",
"trans": "",
"printer": "",
"msg": ""
}
}
2020 Mar 14 7:03 AM
naotoxxx As your JSON string is not a valid JSON the deserialization does nothing. Why your string is not a valid JSON string? Because the opening and closing curly brackets are missing. In the following formatted example of your string, the first and last line I added.
{
"accion": "CREA_LA",
"input": {
"BUKRS": "",
"VSTEL": "",
"VKORG": "",
"FECHA": "",
"CANAL": "",
"SECTOR": "",
"SOLIC": ""
},
"data_cont": {
"pedido": "219135968",
"werks": "1100",
"suppl_plnt": "",
"lotno": "",
"bokno": "",
"kschl": "",
"trans": "",
"printer": "",
"msg": ""
}
}
2020 Mar 14 4:57 PM
Oh man thanks a lot !. From now i'm going to check the format always!
| User | Count |
|---|---|
| 3 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |