☰
Documentation

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=}
SettingsInfo
pathPath to the desired value, like level1/level2/key. Separate keys with /, use numbers for array positions (starting at 0) and do not start the path with /.
not_foundWhat to return if there is no result. Also returned when the value at the path is empty, like "" or 0. Default is an empty string.

When the path points to an object or a list, the result is that part of the JSON, encoded as a JSON string. In HTML output (confirmations, notifications) special characters in the result are HTML-encoded.

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

To get the whole first project as JSON:

{Project Data:1:gwp_json_get path="projects/0"}

This would return: {"Name":"Project Alpha","Status":"Active"}

Frequently Asked Questions

How do I extract a specific value from JSON using gwp_json_get in Gravity Forms?

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"}]}

Why is gwp_json_get not returning a value?

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"}

Where should I use the gwp_json_get merge tag in Gravity Forms?

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}

Can I use gwp_json_get with multiline or pretty JSON?

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"}]}

How do I find the correct JSON path for gwp_json_get?

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"}

How to create a path to a specific JSON value Example Frequently Asked Questions How do I extract a specific value from JSON using gwp_json_get in Gravity Forms? Why is gwp_json_get not returning a value? Where should I use the gwp_json_get merge tag in Gravity Forms? Can I use gwp_json_get with multiline or pretty JSON? How do I find the correct JSON path for gwp_json_get?
Proudly powered by WordPress