That is a little more complicated:

result['json']|default(dict())['ok']|default(0)

There are other ways too, but effectively you have to do it at each level.



On Friday, May 20, 2016, Marcus Morris <[email protected]> wrote:

> One more question:
>
> How do I use default for a variable more than one level down?
>
> such as
>
> result['json']['ok'] | default(0) == 1
>
> that gives me
>
> FAILED! => {
> "failed": true, "msg": "ERROR! The conditional check
> 'result['json']['ok']|default(0) == 1' failed. The error was: ERROR! error
> while evaluating conditional (result['json']['ok']|default(0) == 1): ERROR!
> 'dict object' has no attribute 'json'"}
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected]
> <javascript:_e(%7B%7D,'cvml','ansible-project%[email protected]');>
> .
> To post to this group, send email to [email protected]
> <javascript:_e(%7B%7D,'cvml','[email protected]');>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/bd66d191-e75e-46c5-8e72-d719d720b7dd%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/bd66d191-e75e-46c5-8e72-d719d720b7dd%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Matt Martz
@sivel
sivel.net

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAD8N0v-A3tWHNbEJOe76XunmNTt%2ByV7qVrRSdL6NuoZJY%2BsPZw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to