I have a string which is comming from API request, that looks like big json each element have 2 fields(name, href), after this action I added this name to array:
str_from_api="$(user_groups_json "limit=100" | jq -r '.items | .[].name')"
readarray -t usergroups_array <<< "$str_from_api"
But I need to store 2 variables(name and href) in array usergroups_array. I mean next solution:
Array:
str_from_api=(name:"Test name", href: "Test href")
This array will be long with 100 records. After I need to do operations with each name and each href, that is why I need access to each element of this structure.
How can I implement this?
UPDATE
json:
{
"totalCount": 2,
"items": [
{
"name": "test name",
"active": false,
"createdFrom": "SAML",
"_meta": {
"allow": [
"DELETE",
"GET",
"PUT"
],
"href": "https://href2.com"
}
},
{
"name": "test name 2",
"active": false,
"createdFrom": "SAML",
"_meta": {
"allow": [
"DELETE",
"GET",
"PUT"
],
"href": "https://href1.com"
}
}
]