2021 Sep 02 5:06 PM
Hello Abapers,
I am having an excpetion triggered due to this expression
FIND REGEX '\A\s*"([^:]*)"\s*:' IN SECTION OFFSET l_offset OF json
MATCH OFFSET l_offset MATCH LENGTH l_len
SUBMATCHES l_submatch.
IF sy-subrc NE 0.
RAISE EXCEPTION TYPE zcx_mdp_json_invalid.
ENDIF.
The Json variable value is :
{"evenement":{"Id":"ERROR : No result found for Id :0251407282","Partner":null,"Pod":null,"Contract":null,"Services":null,"Remises":null}}
I don't know what's wrong exactly, I tried to look for documentation but I couldn't find something useful.
Any tips or advice please?
Best regards,
Hello Abapers,
I am having an excpetion triggered due to this expression
FIND REGEX '\A\s*"([^:]*)"\s*:' IN SECTION OFFSET l_offset OF json
MATCH OFFSET l_offset MATCH LENGTH l_len
SUBMATCHES l_submatch.
IF sy-subrc NE 0.
RAISE EXCEPTION TYPE zcx_mdp_json_invalid.
ENDIF.
The Json variable value is :
{"evenement":{"Id":"ERROR : No result found for Id :0251407282","Partner":null,"Pod":null,"Contract":null,"Services":null,"Remises":null}}
I don't know what's wrong exactly, I tried to look for documentation but I couldn't find something useful.
Any tips or advice please?
Best regards,
2021 Sep 02 5:50 PM
My best guess is that the regex is wrong, have you tried to validate using https://regex101.com/
or even report demo_regex (with extended examples on)?
What are you trying to match in the json?
2021 Sep 02 6:28 PM
Your code triggers an exception, but your question is about why the regex doesn't find the value (i.e. why SY-SUBRC = 0). Quickly looking at it, your regex seems wrong:
"([^:]*)"it should be:
"([^"]*)"In fact, if you are trying to do something generic, it's not even handle all the cases, but well that's not the question... Even regex is not recommended for parsing JSON.
(NB: \A is correct only if you play correctly with L_OFFSET, that you should change to go after curly brackets and comma)
2021 Sep 03 11:36 AM
| User | Count |
|---|---|
| 4 | |
| 2 | |
| 2 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 | |
| 1 |