Need help to parse output

Hello, I have a task that loops to get user details in one same server. The exceededCPUUsers contains the list of the users.
For example:
exceededCPUUsers: [user1, user2]

This is the task in a workflow:

    action: core.remote
    with: <% ctx().exceededCPUUsers %>
      username: root
      hosts: "{{ ctx().hostname }}"
      cmd: "checkpkg user={{ item() }}"
      - when: <% succeeded() %>
          - getPackage: <% task(Task3).result %>

It saves the output to getPackage like this :

I’m struggling with the list inside list part (items list and hostname list) .I need suggestion on how to make the output like this:

As you can see the hostname list is merged, and the item() from exceededCPUUsers become keys. I think it’s like changing from nested list into dict inside list.

I really appreciate the help.

What errors are you getting? What YAQL query have you tried so far?

FYI, the example you shared via pastebin ( is not valid JSON.

I tried this query:
<% task(Task3)$.result) %>

So far, it looks like this : Now I don’t know how to merge the item list so the hostname only shows once, and use exceededCPUUsers as key.

The pastebin is correct, except in the final output because I want to illustrate the final output.

The data restructuring you’re attempting to do is too complex for YAQL or Jinja, you’ll need to process it with a general purpose language.

1 Like

Yeah I do think the structure is too complex. I’ll try another way. Thank you for your help.