zcl_mdp_json
zcl_mdp_json copied to clipboard
Error on empty input
I add this issue from Alejandro's comment on the blog post: https://blogs.sap.com/2016/07/03/an-open-source-abap-json-library-zclmdpjson/comment-page-1/#comment-543786
Hello again, Fatih Pense another issue and quick fix for method ZCL_MDP_JSON_DESERIALIZER=>DESERIALIZE (you could document it on github):
On trying to deserialize an empty JSON string, you get the following short dump:
STRING_OFFSET_TOO_LARGE CX_SY_RANGE_OUT_OF_BOUNDS Illegal access to a string (offset too large)
I solved it by adding the following correction to raise the same exception used for other errors:
method deserialize.
data : l_jsonnode type ref to zcl_mdp_json_node.
* correction >>>>>>>> (FIX A.BINDI 2020.12.11)
if json is initial.
raise exception type zcx_mdp_json_invalid.
endif.
* correction <<<<<<<< (FIX A.BINDI 2020.12.11)
deserialize_node(
exporting
json = json
offset_before = 0
importing
jsonnode = l_jsonnode ) .
node = l_jsonnode.
endmethod.