Open huber-nicolas opened 2 years ago
yea, I think so
but I'm not sure what to_mixed/from_mixed do in this case, https://help.sap.com/doc/abapdocu_752_index_htm/7.52/en-US/abencase_functions.htm
https://github.com/SAP/abap-file-formats/blob/main/docs/json.md#writing-json-schema-with-abap-types
I tested it with this coding:
data abap_name type string.
data json_name type string.
data reconstructed_abap_name type string.
abap_name = 'element1'.
json_name = to_mixed( abap_name ).
reconstructed_abap_name = from_mixed( json_name ).
out->write( |abap_name = { abap_name } => to_mixed( ) = json_name: { json_name } => from_mixed( ) reconstructed abap_name from jsonname: { reconstructed_abap_name }| ).
abap_name = 'element_1'.
json_name = to_mixed( abap_name ).
reconstructed_abap_name = from_mixed( json_name ).
out->write( |abap_name = { abap_name } => to_mixed( ) = json_name: { json_name } => from_mixed( ) reconstructed abap_name from jsonname: { reconstructed_abap_name }| ).
abap_name = 'element_1_'.
json_name = to_mixed( abap_name ).
json_name = to_mixed( abap_name ).
reconstructed_abap_name = from_mixed( json_name ).
out->write( |abap_name = { abap_name } => to_mixed( ) = json_name: { json_name } => from_mixed( ) reconstructed abap_name from jsonname: { reconstructed_abap_name }| ).
abap_name = 'element_1_a'.
json_name = to_mixed( abap_name ).
json_name = to_mixed( abap_name ).
reconstructed_abap_name = from_mixed( json_name ).
out->write( |abap_name = { abap_name } => to_mixed( ) = json_name: { json_name } => from_mixed( ) reconstructed abap_name from jsonname: { reconstructed_abap_name }| ).
The output is this: abap_name = element1 => to_mixed( ) = json_name: element1 => from_mixed( ) reconstructed abap_name from jsonname: ELEMENT1 abap_name = element_1 => to_mixed( ) = json_name: element1 => from_mixed( ) reconstructed abap_name from jsonname: ELEMENT1 abap_name = element1 => to_mixed( ) = jsonname: **element1 => from_mixed( ) reconstructed abap_name from jsonname: ELEMENT1_ abap_name = element_1_a => to_mixed( ) = json_name: element1A => from_mixed( ) reconstructed abap_name from jsonname: ELEMENT1_A**
I run into problems when trying to map a json field name back to the corresponding abap field name. This happens when the abap field name has underscores in front of a digit. For example: element_1. In json this will become "element1" and when mapping "element1" back to abap there are 2 possibilities. It could have been "element1" or "element_1" in abap. So should we forbid underscores in front of digits, so that we can reconstruct the abap field name?