FindPropertyPathActivity Activity

Purpose: This activity finds a property value anywhere in a nested JSON object or dictionary. It can search through complex nested structures and return either the first match or all matches found. This is useful for extracting specific values from complex JSON data structures.

Input Properties

SourceObject

The JSON object or string to search. Can be a JSON string, a dictionary, or any object that can be serialized to JSON.

Type: object

Required: Yes

Example: {"user": {"name": "John", "address": {"city": "New York"}}} or a JSON string

PropertyName

The property name to search for in the nested structure.

Type: string

Required: Yes

Example: "city" or "name"

Mode

Search mode: 'First' to return first match, 'All' to return all matches found in the nested structure.

Type: string

Default: "First"

The valid values are:

  • First - Returns only the first property value found
  • All - Returns all property values found throughout the nested structure

Output Properties

Value

The value of the found property (when Mode is "First"). If no property is found, this will be null or empty.

Type: string?

Note: In "All" mode, this will contain the first value found. If an error occurs, this will contain an error message.

Values

The values of all found properties (when Mode is "All"). Returns a list of all matching property values found in the nested structure.

Type: List<string>

Note: In "First" mode, this will contain a list with a single value (the first match) or an empty list if no match is found.

Usage Example

Scenario: Find a property value in a nested JSON structure

Configuration:
- SourceObject: {"user": {"name": "John", "address": {"city": "New York", "country": "USA"}}, "settings": {"city": "Boston"}}
- PropertyName: "city"
- Mode: "First"

Result:
- Value: "New York" (first match found)
- Values: ["New York"] (single value in list)

Scenario: Find all occurrences of a property

Configuration:
- SourceObject: {"user": {"name": "John", "address": {"city": "New York"}}, "settings": {"city": "Boston"}}
- PropertyName: "city"
- Mode: "All"

Result:
- Value: "New York" (first match)
- Values: ["New York", "Boston"] (all matches found)

Error Handling

Important: The activity handles errors gracefully:

  • If SourceObject or PropertyName is null or empty, both outputs will be set to null/empty
  • If the JSON string is invalid and cannot be parsed, a JsonException will be caught and Value will contain: "JSON parsing error: {error message}"
  • Any other unexpected errors will be caught and Value will contain: "Unexpected error: {error message}"
  • When errors occur, Values will be set to an empty list

Always check for error messages in the Value output before using the results in subsequent activities.

Important Notes

  • The activity searches recursively through all nested objects and arrays
  • Property names are matched exactly (case-sensitive)
  • If the source is a JSON string, it will be parsed first
  • If the source is an object, it will be converted to JSON format for searching
  • Use "First" mode when you only need one value and want better performance
  • Use "All" mode when you need to find all occurrences of a property name in the structure
  • The search traverses both objects and arrays in the JSON structure

Related Activities