JMESPathTypeError when using json_query filter in Ansible with starts_with

The problem is that json_query filter expects to get a dictionary with ascii strings, but what you're providing it are unicode strings (notice the u'blabla' in your input).

This is an issue with json_query that apparently got introduced in Ansible 2.2.1 (although that is not really clear), here are some more details: https://github.com/ansible/ansible/issues/20379#issuecomment-284034650

I hope this gets fixed in a future version, but for now this is a workaround that worked for us:

"{{ results | to_json | from_json | json_query(jmespath_query) }}"

Where jmespath_query is a variable that contains a starts_with query. This trick of going to and from json turns the unicode strings into ASCII ones :)