Get basic values in FQL

FQL uses location path syntax to extract values from JSON structures. The following examples show several examples of getting basic values from JSON data.

Example JSON

The examples below use this JSON data:

{
    "name": "John Smith",
    "address": {
        "street": "123 Park Avenue",
        "city": "Atlanta",
        "state": "GA",
        "zip": "12345"
    },
    "phones": [
        {
            "type": "Home",
            "number": "123-456-7890"
        },
        {
            "type": "Cell",
            "number": "098-765-4321"
        }
    ],
    "display name": "myuser123"
}

Get a top-level field

To access a top-level field with FQL, enter the field's name.

FQLname
Result"John Smith"

Get a nested field

To access fields below the top level, use field names separated by dot . delimiters.

FQLaddress.city
Result"Atlanta"

Get an entire object

Enter the name of an object in the JSON file to retrieve all the data within that object.

FQLaddress
Result
{
    "street": "123 Park Avenue",
    "city": "Atlanta",
    "state": "GA",
    "zip": "12345"
}
    

Select a specific index in an array

To access individual values in an array in a JSON file, specify an index number between square brackets after the array's name.

FQLphones[0].number
Result"123-456-7890"

Select an entire array

Enter the name of an array in the JSON file to retrieve all the data within that array.

FQLphones
Result
[
    {
        "type": "Home",
        "number": "123-456-7890"
    },
    {
        "type": "Cell",
        "number": "098-765-4321"
    }
]

Return one field of every object in an array

To return a specific field from multiple objects in an array, enter the array's name then the field's name, separated by a dot.

FQLphones.number
Result["123-456-7890","098-765-4321"]

Return fields that contain special characters in the key name

If a field in the JSON file has special characters (like spaces), put the field's name in single quotes.

FQL'display name'
Resultmyuser123

Get the number of elements in a list

FQL$count(phones)
Result2

Last modified: 2024/06/04