Forgive the noob question. I am new to Ansible. I am attempting to filter 
the json results of my playbook to only get specific information. Looking 
at the Ansible documentation, it is possible using 
community.general.json_query. It appears to work on some of the data but I 
am unable to come up with the correct syntax for what I need. Below is some 
sample output along with a snippet of my code. Please help me with the 
correct syntax. Thanks!

I am trying to get only the value of "author".

My code snippet:
- name:
        ansible.builtin.debug:
          var: item
        loop: "{{ results | 
community.general.json_query('json.body[*].book_details') }}"

Sample json output:
    "ansible_loop_var": "item",
    "item": {
        "asterisk": 0,
        "bestsellers_date": "2016-12-31",
        "book_details": [
            {
                "age_group": "",
                "amazon_product_url": 
"https://www.amazon.com/Undoing-Project-Friendship-Changed-Minds-ebook/dp/B01GI6S7EK?tag=NYTBSREV-20";,
                "author": "Michael Lewis",
                "book_image": 
"https://storage.googleapis.com/du-prd/books/images/9780393254600.jpg";,
                "book_uri": 
"nyt://book/5ecd45ad-8552-5f5f-8d7b-6ab0bb3bf624",
                "contributor": "by Michael Lewis",
                "contributor_note": "",
                "description": "How the psychologists Daniel Kahneman and 
Amos Tversky upended assumptions about the decision-making process and 
invented the field of behavioral economics. Their close friendship and 
porous collaboration style became one of the greatest partnerships in the 
history of science.",
                "price": "0.00",
                "primary_isbn10": "0393254593",
                "primary_isbn13": "9780393254594",
                "publisher": "Norton",
                "title": "THE UNDOING PROJECT"
            }
        ],


 

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/13cdcdba-2b12-442c-a4ae-38de53b8add3n%40googlegroups.com.

Reply via email to