The basic idea to add item(s) to an existing array is to create an array of array(s) and then flatten it.
As an example, a totally static query like
[['a', 'b', 'c'], ['d', 'e']][]
Will give:
[
"a",
"b",
"c",
"d",
"e"
]
Now, since you are not giving a desired output, there are multiple cases:
- You want to add one hardcoded item to the array
resource_access."info-bi-test".roles
, and have a simple array as return, with a desired output like
["DB7", "DB9"]
Then, this could be achieved with the query:
[resource_access."info-bi-test".roles, 'DB9'][]
- You want to add multiple items to the array
resource_access."info-bi-test".roles
, and have a simple array as return, with a desired output like
["DB7", "DB9", "DB11"]
Then, this could be achieved with the query:
[resource_access."info-bi-test".roles, ['DB9', 'DB11']][]
- You want to add one item to the array
resource_access."info-bi-test".roles
form somewhere else in the JSON structure, with an input like
{
"resource_access":{
"info-bi-test":{
"roles":[
"DB7"
]
}
},
"default_role": "DB9"
}
and have a simple array as return, with a desired output like
["DB7", "DB9"]
Then, this could be achieved with the query:
[resource_access."info-bi-test".roles, default_role][]
- You want to add multiple items to the array
resource_access."info-bi-test".roles
form somewhere else in the JSON structure, with an input like
{
"resource_access": {
"info-bi-test": {
"roles":[
"DB7"
]
}
},
"default_roles": [
"DB9",
"DB11"
]
}
and have a simple array as return, with a desired output like
["DB7", "DB9", "DB11"]
Then, this could be achieved with the query:
[resource_access."info-bi-test".roles, default_roles][]
- You want to add one hardcoded item to the array
resource_access."info-bi-test".roles
, but you want the whole object structure returned, with a desired output like
{
"resource_access": {
"info-bi-test": {
"roles": [
"DB7",
"DB9"
]
}
}
}
Then, you will have to recreate the object structure in the query:
{
resource_access: {
"info-bi-test": {
roles: [resource_access."info-bi-test".roles, 'DB9'][]
}
}
}
- You want to add multiple hardcoded items to the array
resource_access."info-bi-test".roles
, but you want the whole object structure returned, with a desired output like
{
"resource_access":{
"info-bi-test":{
"roles":[
"DB7",
"DB9",
"DB11"
]
}
}
}
Then, you will have to recreate the object structure in the query:
{
resource_access: {
"info-bi-test": {
roles: [resource_access."info-bi-test".roles, ['DB9', 'DB11']][]
}
}
}
- You want to add one item to the array
resource_access."info-bi-test".roles
form somewhere else in the JSON structure, with an input like
{
"resource_access":{
"info-bi-test":{
"roles":[
"DB7"
]
}
},
"default_role": "DB9"
}
but you want the whole object structure returned, with a desired output like
{
"resource_access":{
"info-bi-test":{
"roles":[
"DB7",
"DB9"
]
}
}
}
Then, you will have to recreate the object structure in the query:
{
resource_access: {
"info-bi-test": {
roles: [resource_access."info-bi-test".roles, default_role][]
}
}
}
- You want to add multiple items to the array
resource_access."info-bi-test".roles
form somewhere else in the JSON structure, with an input like
{
"resource_access":{
"info-bi-test":{
"roles":[
"DB7"
]
}
},
"default_roles": [
"DB9",
"DB11"
]
}
but you want the whole object structure returned, with a desired output like
{
"resource_access":{
"info-bi-test":{
"roles":[
"DB7",
"DB9",
"DB11"
]
}
}
}
Then, you will have to recreate the object structure in the query:
{
resource_access: {
"info-bi-test": {
roles: [resource_access."info-bi-test".roles, default_roles][]
}
}
}
So, as you can see, they are all flavour of the same principle: nest everything in an array and flatten it.