Update get_value

This commit is contained in:
Feodor Fitsner 2025-02-26 16:58:23 -08:00
parent 94ef48fafc
commit 920164060e
1 changed files with 5 additions and 2 deletions

View File

@ -7,13 +7,16 @@
{# Initialize the result with the input dictionary #} {# Initialize the result with the input dictionary #}
{% set result = dict %} {% set result = dict %}
{# Use a flag to detect when to stop processing #}
{% set valid = true %}
{# Iterate through the keys and traverse the dictionary #} {# Iterate through the keys and traverse the dictionary #}
{% for key in keys %} {% for key in keys %}
{% if result is mapping and key in result %} {% if valid and result is mapping and key in result %}
{% set result = result[key] %} {% set result = result[key] %}
{% else %} {% else %}
{% set result = none %} {% set result = none %}
{% break %} {% set valid = false %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}