Refactor tpl parsing to occur before json_decode

This allows construction of JSON expressions from the placeholders rather than limiting the replacements to JSON values