Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 657

JQ extract array id of an object

$
0
0

I have this input data :

{"list": {"1": {"attributes": {"content": [],"pageable": {"pageNumber": 0,"pageSize": 10                }            }        },"2": {"attributes": {"content": [                    {"id": "AZER"                    }                ],"pageable": {"pageNumber": 0,"pageSize": 10                }            }        },"3": {"attributes": {"content": [                    {"id": "WXC"                    },                    {"id": "QSD"                    }                ],"pageable": {"pageNumber": 0,"pageSize": 10                }            }        }    }}

I need to use JQ to extract the id values into a new array, I try this:

.list[] | .attributes.content[].id

that's my results:

"AZER""WXC""QSD"

It's what i want but in 3 line and i need to have it in arrayHow can i make this results in an array like this:

["AZER","WXC","QSD"]

Viewing all articles
Browse latest Browse all 657

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>