Operators
Operators are special language features that alter the normal output of a query or perform a specific function.
Array indexing
As a way to access a specific element inside an array at a given position, we have integrated inside GQ the array
indexing syntax. To do so, into an array field, you can specify the desired index enclosed in [].
Given the following input:
{ "companies": [ { "name": "Apple", "marketCap": 3.286 }, { "name": "Microsoft", "marketCap": 3.206 }, { "name": "Nvidia", "marketCap": 2.866 } ]}If we want to obtain the first element in the companies array, we can apply the next query:
companies[0]{ "name": "Apple", "marketCap": 3.286}This is also compatible with the dot operator or any previously explained concept:
companies[1].name"Microsoft"