JSON_EXTRACT is a powerful tool in Sheet Workflows that extracts specific data from JSON strings in Google Sheets. It simplifies parsing complex JSON data without requiring technical expertise in JSON or JavaScript.
=JSON_EXTRACT(jsonString, [field])
Parameter | Data Type | Required | Description |
---|---|---|---|
jsonString |
|
Required | The JSON string to extract data from. This can be in a cell reference or directly in the formula. |
field |
|
Optional | The name of the field to extract. Returns all occurrences for a single key or navigates nested structures using chained expressions with
|
When you pass a single key, JSON_EXTRACT finds all occurrences of that key anywhere in the JSON structure.
=JSON_EXTRACT(A1, "name")
Use chained key expressions with
<
=JSON_EXTRACT(A1, "city<address<person")
When a field contains a nested object or array, the function returns the object's keys as separate values if it's a nested object, the array's elements as separate values if it's a nested array, or the primitive value for non-nested content.
This example demonstrates extracting a simple field from a JSON object.
=JSON_EXTRACT(A1, "name")
Expected output:
John Doe
This example shows how the function extracts multiple occurrences of a field from a JSON structure containing several objects.
=JSON_EXTRACT(A1, "name")
Expected output (in multiple cells):
Alice
Bob
Charlie
Diana
This example demonstrates navigating nested JSON structures using a chained key expression.
=JSON_EXTRACT(A1, "city<address<person")
Expected output (in multiple cells):
New York
Boston
This error occurs when the input string is not valid JSON due to missing commas, brackets, quotes, unescaped special characters, or trailing commas.
Solution: Validate your JSON using an online JSON validator and fix any syntax errors.
This error occurs when the specified field does not exist in the JSON.
Solutions: Check for typos in the field name, verify the JSON structure, and ensure correct capitalization for case-sensitive fields.
If the results appear as [object Object] or contain escaped quotes, it means that the extracted value is an object or array.
Solutions: Use a more specific field path to extract primitive values or combine with additional functions like SPLIT() or REGEXEXTRACT() to further process the results.
Yes, JSON_EXTRACT will search through arrays and extract fields from any objects they contain.
You need separate JSON_EXTRACT calls for each field. Consider using multiple columns or a custom formula to combine the results.
Yes, field names in JSON are case-sensitive. For example, "Name" and "name" are treated as different fields.
Yes, the function works well with API responses. Use Sheet Workflows' HTTP functions to fetch the data, then JSON_EXTRACT to parse it.
Null values are returned as empty strings, and undefined fields will result in a "Field not found" error.
There is no practical limit to the depth of JSON the function can search through.
No, the function supports simple key names and chained paths but does not support wildcards or array indexing. For more complex cases, extract a broader section and refine with additional functions.
3 months ago