I have following JSON which I get using API. The json has 2 list, 1- main_roles and 2- cc_roles. Using following code I can get 1 list. But I want to get both list in dropdown(display, value).
How can I get both list 1- main_roles and 2- cc_roles in 1 jq using map?
JSON
{
"invoice": {
"invoice_id": "b494a46396e47726873708f71a71a228ba2782fa",
"main_roles": [
{
"name": "Agent"
},
{
"name": "Customer"
}
],
"cc_roles": [
{
"name": "Manager"
}
]
}
}
JSON Code
"select": {
"label": "Invoice",
"form_fields": [
{
"label": "Select Role",
"id": "selectRole",
"type": "dropdown",
"required": true,
"options": {
"!pipe": [
{
"!http": {
"method": "GET",
"path": "https://api.test.com/getroles"
}
},
{
"!jq": ".invoice.main_roles | map({ display: .name , value: .name })"
}
]
}
}
]
}