Open ghTravis opened 5 months ago
This could perhaps be supported by way of the flag added in #1948/#1949. It'll take a bit of wiring but I think it's feasible.
@ghTravis are you willing to try implementing this? Otherwise it's likely to take a while for me to get around to this.
Hi,
I am trying to use
coll.JSONPath
to evaluate a particular key path structure but if for whatever reason the path does not exist, the template generation errors with error:You can test this by running the following gomplate command:
It would be great if JSONPath could support returning empty values when the path is not found, perhaps based on the
missingKey
setting. Some support in favor of adding this capability tocoll.JSONPath
can be seen in this comparison doc of the various different supporting libraries for JSONPath that have support for "empty" return values.It could be as simple as changing this line of code to honor the
missingKey
value https://github.com/hairyhenderson/gomplate/blob/main/coll/jsonpath.go#L53=== Gomplate Version: v4.0.0-pre-2