Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Event-Grid - Double json serialization by oref_eventgrid->set_eventgrid_schema #134

Closed
bdelangh opened this issue Feb 14, 2023 · 3 comments

Comments

@bdelangh
Copy link

Hello,
The oref_eventgrid->set_eventgrid_schema method does a json serialization of the gt_egrid_schema input parameter, although the data payload of the structure is mostly already a string in a json format. This results in escaping the existing json string. Eg. a " is converted to /" by escaping the " character. The data payload is then also not considered a json anymore by the event hub. So things like filtering in the event grid subscription don't work anymore.

Example :
{
"subject": "OnlineShop/Order/Created",
"eventtype": "onlineshop.order.created",
"id": "12345678",
"data": "{"ordernr":"12345678","createdby":"DEVELOPERBD",**"event":"**created","date":*"2023-02-14","**time":*"**08:21:30"}",
"dataversion": "2.0",
"metadataversion": "1",
"eventtime": "2023-02-14T08:21:30Z",
...
}

This behaviour also occurs in the sample program:

oref_eventgrid->set_eventgrid_schema( EXPORTING it_egrid_schema = lt_payload
RECEIVING rv_xstring = DATA(lv_pxstring) ).

where ls_payload-data = lv_json_string.

And previously :
** Convert Data into json format
/ui2/cl_json=>serialize(
EXPORTING
data = lv_event_data
compress = abap_true
pretty_name = /ui2/cl_json=>pretty_mode-camel_case
RECEIVING
r_json = lv_json_string ).

Would it be possible that the payload-data is not serialized or that we can have a generic (nested) structure as input?

Greetings,
Bart

@vikasbansal2022
Copy link
Contributor

Hello @bdelangh,

Thanks for reaching out. The payload-data has to be the JSON format as per the event Payload Grid Schema. So, the Payload-Data can have any number of name entity and there is no specific type. The final payload schema should also be in the Json format. So, there is requirement to convert payload-data as well as the whole payload schema in the Json format.

Since you are looking to filter out based on payload-data in event Hub. The escape character /" will cause problem. I will make some adjustments set_eventgrid_schema->set_eventgrid_schema to make Payload-data Json as valid.

Regards,
Vikas

@vikasbansal2022
Copy link
Contributor

Hello @bdelangh.

We pushed another demo program "ZADF_EVENTGRID_ANY_DEMO. " This program has the demo of generic type of Deep Structure having Dynamic internal table as payload.

Also made some adjustments to class method zcl_adf_service_eventgrid~set_eventgrid_schema to accommodate Dynamic deep structure. Please let me know us know if you still face issue in Even hub receiver.

Good news is now you can have generic (nested) structure as input in payload-data.

Regards,
Vikas

@bdelangh
Copy link
Author

Thanks, works with the demo program

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants