zcl_mdp_json
zcl_mdp_json copied to clipboard
null value is ignored
As reported by Yves,
JSON causing the error
{ "SI": [{"zzreference": "1/53201/2018/000001", "land1": null, "fwbas": "40.10", "wears": "EUR", "stcteg": null, "kursf": "1", "wmwst": "0.00", "stras": null, "zztrans": "INSTOR", "pstlz": null, "budat": "2018-02-06", "wrbtr": "40.10", "ort01": null, "vat_rate": "0.0", "name1": null, "bidat": "2018-02-06"},
Fix
METHOD deserialize_node.
DATA l_json TYPE string.
l_json = json.
DATA l_offset TYPE i.
l_offset = offset_before.
DATA(lv_offset_null) = offset_before.
DATA l_len TYPE i.
DATA : l_jsonnode TYPE REF TO zcl_mdp_json_node.
FIND REGEX ‘\{|\[|”|\d|t|f’ IN SECTION OFFSET l_offset OF json
MATCH OFFSET l_offset.
* correction >>>>>>>>
FIND REGEX ‘\{|\[|n|\d|t|f’ IN SECTION OFFSET lv_offset_null OF json
MATCH OFFSET lv_offset_null.
IF lv_offset_null LT l_offset.
l_offset = lv_offset_null.
ENDIF.
* correction <<<<<<<<
CASE l_json+l_offset(1).