yaql list iterator

Asked by ritesh nanda

I have data in such way.

{
"result": [
            {
                "ID": "e424b323-8259-47aa-a0b1-8e28104076af",
                "Name": "test",
                "Networks": "net=10.31.195.77",
                "Status": "ERROR"
            },
            {
                "ID": "3ece6482-1359-474c-b5ad-70bced8013ed",
                "Name": "test",
                "Networks": "net=10.x.x.x",
                "Status": "ACTIVE"
            },
            {
                "ID": "5e606e22-752f-4991-8213-02e3c4bd6152",
                "Name": "test",
                "Networks": "net=10.x.x.x",
                "Status": "ACTIVE"
            },
            {
                "ID": "08b2efec-7fde-40ce-9366-1f459f14a3ce",
                "Name": "test",
                "Networks": "net=10.x.x.x",
                "Status": "ACTIVE"
            },
            {
                "ID": "b1bf899b-79c0-4fde-bc17-a1b071b5f2ce",
                "Name": "test_ubuntu12",
                "Networks": "net=10.x.x.x",
                "Status": "ACTIVE"
            }
]
}

 $.result.where($.Status="ACTIVE").select($.Networks)

Gives me

[
    "net=10.x.x.x",
    "net=10.x.x.x",
    "net=10.x.x.x",
    "net=10.x.x.x"
]

I want to iterate inside this using loop or something yaql has and use split function of yaql .split("=")[1] to get just the ips.

Question information

Language:
English Edit question
Status:
Answered
For:
YAQL Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Sam (sjtindell) said :
#1

You will want to do this with a filter.

There is a map function.

In this case you want to map the split function to each of the returned values.

e.g.

$.result.where($.Status="ACTIVE").select($.Networks).map($.split("=")[1])

Best,
Sam Tindell

Can you help with this problem?

Provide an answer of your own, or ask ritesh nanda for more information if necessary.

To post a message you must log in.