4 weeks ago
Hi there!
I have a webhook that changes the payload based off of the type of event being fired. What I wanted to do was make a lookup table with the event type (which is included in all calls) and matches with the JSON for the payload type. This way, all I have to do is a Lookup table search, and if anything is returned, do 1 parse. This would be very clean.
The problem is the PARSE JSON by Workato tool does not allow the interpretation of the lookup table field for the format of the document to parse. It appears to change the format from {"Key": "value"} to something like {"key"=>"value"}.
Is there a clean way I can do this, without resorting to a long line of IF statements or including all possible payload values in the schema, so you can't tell from looking which values will be null and which won't? I would appreciate any advice you can provide!
Solved! Go to Solution.
4 weeks ago
The format you're seeing is Ruby syntax for hashes. You could use .to_json to convert the Ruby hash to JSON.
That said, this plan will work but it has one major flaw. If you provide a data pill as input to the JSON parser action, the action won't have any output data pills to use in subsequent actions of your recipe.
The JSON parser action uses the static sample document to create output data pills. If you use a data pill as a sample doc, the pill has no value outside of job run-time (until it's set by your lookup table), so the JSON action in the recipe editor doesn't know what output pills to make.
I've implemented a lot of message broker recipes like this and each time I used multiple if conditions based on the event type with a JSON parser that corresponds to the expected payload. It keeps everything pretty modular and I found this easier to maintain than having one "super schema" containing all possible values for all possible payloads.
4 weeks ago
The format you're seeing is Ruby syntax for hashes. You could use .to_json to convert the Ruby hash to JSON.
That said, this plan will work but it has one major flaw. If you provide a data pill as input to the JSON parser action, the action won't have any output data pills to use in subsequent actions of your recipe.
The JSON parser action uses the static sample document to create output data pills. If you use a data pill as a sample doc, the pill has no value outside of job run-time (until it's set by your lookup table), so the JSON action in the recipe editor doesn't know what output pills to make.
I've implemented a lot of message broker recipes like this and each time I used multiple if conditions based on the event type with a JSON parser that corresponds to the expected payload. It keeps everything pretty modular and I found this easier to maintain than having one "super schema" containing all possible values for all possible payloads.
4 weeks ago
@gary1 I will start mapping it out as you suggested with if conditions. Thank you so much for your input!