Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello !
I'm trying to read the data sent to a job using the webhook URL. I see that I'm getting the payload as a json array, where I have the "data" field containing what I need.
but what I don't know how to do is :
-how can i parse this json content ? I see Json components, but based on fields or files, and I don't know how to convert my context to one of those
-once I will have this data value, how can I decode it ? It's a simple base64 encoding, so I guess a simple tjava or tjavarow, with the right function ?
Thanks in advance for any help 🙂
I tried with a simple tjava component, with this code :
JSONObject obj=new JSONObject(context.resource_webhook_payload);
context.email_requester=obj.getString("data");
but it's refusing to read the json object, as there are "[]" around it. How can I read the content ?
@François Tissandier , take a look at this topic, and try the code used to decode the base64 string on tJavaRow.
Regards
Shong
Thanks for the answer ! But before being able to decode anything, I need to have the value first 🙂
ANd "context.resource_webhook_payload" contains the json payload, but with [ ] around it. So "new JSONObject(" isn't working. How can I make it read the Json part within the [ ] ?
@François Tissandier , remove the [ ] from the string using expression:
JSONObject obj=new JSONObject((context.resource_webhook_payload.replaceAll("[","")).replaceAll("]",""));
Indeed, quite simple and it's working !
Is it possible to decode the base64 content ? I can't find a simple way to do it in my tjava component 😞