Power tip: Inline function to grab JSON Value
This little gem dramatically reduces the number of JSON extracts required to reference and use a value from a JSON structure without requiring local variable space for each element. I have a number of early automations that are filled with local extracted variables for the sole purpose of moving the value into another JSON structure, database, log file, etc.
inline %func%:JsonValue changes the game. For example, implementing an omni-channel order confirmation solution, the initial automation for each channel creates a common JSON structure for the called automation that sends the order confirmation via one of several email types (Amazon requires plain text, for other channels we can use our email forwarder with its slick templating language).
Prior to the inline %func%:JsonValue, the called automation would have to extract each and every element of the JSON simply to rearrange for the target email confirm. With %func%:JsonValue, however, any value passing through from the %Msg_Body% to the target format can be referenced directly like this excerpt:
Just one more tip showing off the brilliant power of TA5!
- 1 replies
- MMark Carpenter @mark.carpenter
I thought to try using the %func%:Format to convert a decimal from positions to two...it works brilliantly, sort of reminds me of LISP but not in an RPN way.
Within the JSON (using Set Variable) it modified the value from 13.5091 to 13.51