@peternlewis:
Can you please add your standard "Failure Aborts Macro" and "Notify on Failure" options to the "Set Variables to JSON" action? Which of course also means setting "%ActionResult%".
I have use cases where I want to take specific action if the action fails.
Thanks!
1 Like
The action can currently fail if:
- The prefix is not valid. This requires that the prefix have a token in it, otherwise it will refuse to be saved with an actively invalid prefix like “A-B”
- The JSON is not valid.
- One or more of the keys in the JSON top level dictionary/array is not a valid name (an array key (being a number) would always be a valid name is the prefix is non-empty).
Currently, invalid key names are simply ignored, they are not errors.
The action incorrectly considered it impossible to fail if the prefix was valid. I have corrected that, so the action now knows it can also fail if the JSON is invalid.
Also, I have extended the testing so that if every key results in an invalid variable, that is considered a failure. However, if the prefix is valid, and the JSON is valid, and at least one key results in a valid variable to set (or if there are no keys), that is considered a success, even though other keys may be ignored.
So for example, with JSON like:
{ "good" : "value", "-123" : "bad key" }
the action will succeed (presuming the prefix is valid or empty).
Similarly,
{ "1234" : "value", "5678" : "value" }
the action will succeed if the prefix is valid and non-empty, but fail if it is empty since no keys are valid variable names.
And finally,
{ }
the action will succeed if the prefix is valid or empty, since there are no invalid keys.
This is all done for the next version.
1 Like