# jinja2\_native behavior

**URL:** <https://forum.ansible.com/t/jinja2-native-behavior/38704>\
**Category:** Ansible Project\
**Created:** [March 4, 2024, 5:58pm UTC](https://forum.ansible.com/t/jinja2-native-behavior/38704 "2024-03-04T17:58:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Walter\_Rowe](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/walter_rowe/32/4506_2.png) [@Walter\_Rowe](https://forum.ansible.com/u/Walter_Rowe)\
**Post date:** [March 4, 2024, 5:58pm UTC](https://forum.ansible.com/t/jinja2-native-behavior/38704/1 "2024-03-04T17:58:47Z")

</div>

Is this expected behavior?

% ANSIBLE\_JINJA2\_NATIVE= **true** ansible -i localhost, localhost -m debug -a var=this -e “this=‘None’”

localhost | SUCCESS =\> {

“this”: null

}

% ANSIBLE\_JINJA2\_NATIVE= **false** ansible -i localhost, localhost -m debug -a var=this -e “this=‘None’”

localhost | SUCCESS =\> {

“this”: “None”

}

Just making sure that jinja2\_native=True _should convert_ a string value of “None” to value _null_ when evaluated.

Walter

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [March 4, 2024, 6:16pm UTC](https://forum.ansible.com/t/jinja2-native-behavior/38704/2 "2024-03-04T18:16:29Z")

</div>

As of now, yes. Non-native jinja only runs things that look like a `list`, `dict`, `set`, `bool` through `ast.literal_eval`, leaving everything else as a `str`. Native sends everything through `ast.literal_eval`.

If instead you used `-e "this='[None]'"` you would notice that it becomes `[null]` on both, due to it appearing as a list.

However, this may be changing in 2.17 or 2.18, as changes are being made to how native jinja works, by making it native through the whole jinja process. As such, it would leave the string ‘None’ as a string. Also, non-native will go away at that point, since it will more closely act like most expect.
