gwp_json_get
When a JSON string is stored as a Gravity Forms Field value, the gwp_json_get
modifier decodes the JSON and returns the value specified by the provided JSON path. This enables users to dynamically extract nested information from complex JSON data structures.
{JSON String:1:gwp_json_get path= not_found=}
Settings | Info |
---|---|
path | Path to the desired value, like level1/level2/key |
not_found | What to return if the there is no result. |
How to create a path to a specific JSON value
For our API Connector Add-on we created a JSON path parse tool which outputs all the possible paths from a JSON string.
Example
Consider a Gravity Forms Text Field with label Project Data (field id 1) that has the following JSON as a value:
{
"projects": [
{
"Name": "Project Alpha",
"Status": "Active"
},
{
"Name": "Project Beta",
"Status": "Completed"
}
]
}
To extract the name of the first project:
{Project Data:1:gwp_json_get path="/projects/0/Name" not_found="No project found"}
This would return: Project Alpha
Frequently Asked Questions
To extract a nested value from a JSON string submitted in a Gravity Form field, use the gwp_json_get merge tag. This modifier reads a JSON string, follows the given path, and returns the value perfect for API responses or complex data structures.
Make sure:
– The JSON string is valid (no line breaks, properly formatted)
– The input field is a Single Line Text field
– The JSON path is correctly written (e.g., projects/0/Name)
Example:{Input:9:gwp_json_get path="projects/0/Name" not_found="No project found"}
This returns “Project Alpha” when the submitted JSON looks like this:{"projects":[{"Name":"Project Alpha","Status":"Active"},{"Name":"Project Beta","Status":"Completed"}]}
If gwp_json_get returns your not_found fallback value (or nothing at all), it’s often because:
– The JSON input has line breaks or is malformed
– The field type is Paragraph Text, which may insert unwanted characters
– The JSON path is incorrect or doesn’t match the structure
Fix: Use a Single Line Text field, paste a clean JSON string, and double-check your path.
Example fix:{"projects":[{"Name":"Alpha"}]}
{Input:9:gwp_json_get path="projects/0/Name" not_found="Missing name"}
You can use the gwp_json_get modifier inside:
– The Default Value of another field (like a Hidden field)
– Confirmation messages
– Notifications
– Any place GravityWP Advanced Merge Tags are supported
It’s often paired with a Hidden field to extract data automatically from another field.
Example:{Input:9:gwp_json_get path="projects/1/Name"}
Then show it later in a message:Extracted Name: {Hidden Field:8}
No, it’s highly recommended to avoid line breaks. gwp_json_get expects a single-line, compact JSON string. Line breaks or improperly escaped characters will break parsing.
Instead of this:{
"projects": [
{
"Name": "Alpha"
}
]
}
Use this:{"projects":[{"Name":"Alpha"}]}
Use the GravityWP JSON Path Tool to automatically generate valid paths from a JSON string. This helps avoid mistakes like typos or missing array indexes.
Example path:projects/0/Name
Paste your JSON into the tool, copy the path you need, and insert it into your merge tag like this:{Input:9:gwp_json_get path="projects/0/Name"}
Last updated: 21-07-2025