FQL uses location path syntax to extract values from JSON structures. The following examples show several examples of getting basic values from JSON data.
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"
}
To access a top-level field with FQL, enter the field's name.
FQL | name |
Result | "John Smith" |
To access fields below the top level, use field names separated by dot .
delimiters.
FQL | address.city |
Result | "Atlanta" |
Enter the name of an object in the JSON file to retrieve all the data within that object.
FQL | address |
Result |
{ "street": "123 Park Avenue", "city": "Atlanta", "state": "GA", "zip": "12345" } |
To access individual values in an array in a JSON file, specify an index number between square brackets after the array's name.
FQL | phones[0].number |
Result | "123-456-7890" |
Enter the name of an array in the JSON file to retrieve all the data within that array.
FQL | phones |
Result | [ { "type": "Home", "number": "123-456-7890" }, { "type": "Cell", "number": "098-765-4321" } ] |
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.
FQL | phones.number |
Result | ["123-456-7890","098-765-4321"] |
If a field in the JSON file has special characters (like spaces), put the field's name in single quotes.
FQL | 'display name' |
Result | myuser123 |
FQL | $count(phones) |
Result | 2 |
Last modified: 2024/06/04
Additional resources
Videos
Blog posts