In a config modifier, a selector is the JSON path of the field that the modifier should act upon. In other words, the selector determines where a config modifier's defined processing should happen within a payload.
By designating the path and using config modifier keywords, you can choose which action should happen on the specified selector. There's intentionally a lot of flexibility. You can overwrite existing values and arrays, add to existing arrays, or build new arrays altogether.
This article contains guidelines for writing your selectors and config modifiers based on what action you want to occur on the payload.
There are different ways to choose or write a selector for a config modifier. It largely depends on which format the data is in.
For Redox data models or FHIR® resources, follow the guidelines for choosing a selector from a drop-down list.
For all other formats, follow the guidelines for writing a selector.
Because of format differences, you might use paths like any of these for different formats:
Format | Selector example |
---|---|
Redox data model | $.Visit.Insurances[*].Plan.ID |
Redox FHIR® | $.entry[?(@.resource.resourceType=="Patient")].resource.address[*].state |
HL7v2 | $.INSURANCE[*].IN1.2.1 |
If you're targeting a field path from a Redox data model or FHIR® resource, select the field path from a drop-down list. The drop-down list is comprehensive for data models but not for FHIR® paths (there are too many possibilities with FHIR® to show all the options).
You can manually edit the field path after you've chosen it from the drop-down.
If you're targeting a field path for any other format (i.e., not a Redox data model or FHIR® resource), you must write the JSON path from scratch. If needed, find the field path in the input payload snapshot for reference.
Then, review a help article and refer to these JSONPath expressions to help write your JSON path correctly:
Expression | Notes |
---|---|
$ | The root object or element. The start of your path must contain $. |
@ | The current object or element. |
@root | The root node. |
@parent | The parent node. |
. or [] | The child operator. |
.. | Recursive descent. JSONPath borrows this syntax from E4X. |
* | Wildcard. Includes all objects or elements, regardless of their names. |
[?(...)] | Applies a filter expression (for arrays). |
== or && or || | Direct equality and boolean comparison operators (< and > aren't allowed). |
Instead of writing a path, you can also copy a selector path from a JSON payload within log inspector. All you have to do is find an operation with the JSON payload snapshot you want to act on.
- Within log inspector, find an operation with one or more JSON payload snapshots.
- Find the array or field you want to target with the config modifier.
- Right-click on the array or field. Three copy options display in the menu:
- Copy selector - wildcard
- This option copies the path with an * to match on ALL items within the selected array (i.e., $my.array[*].field). If there isn't an array, this copies the same path as Copy selector - exact.
- Copy selector - exact
- This option copies the path to match on ONLY the selected item in the array (i.e., $my.array[1].field).
- Copy get path
- This option copies the path used for the get operation within a config modifier schema (i.e., my.array[1].field).
An asterisk (*) indicates that all objects or elements should be included, regardless of their name. You can use asterisks in selectors to indicate that all items within an array should be acted upon.
Use an asterisk (*) at the end of an array path name to operate on all elements within an array.
Let's say you have this initial payload:
You want to replace everything inside ArrayPath. So you would write this selector:
And build a config modifier schema with a keyword like this:
These would produce this output payload:
Since they original values in the array are replaced, you'd end up with the same number of values that existed in the input. However, they'd be replaced with the new values indicated in the config modifier schema.
Use an asterisk (*) at the end of the array path name to operate on all elements within an array. However, if you only want to operate on specific elements within the array, add the element name without an asterisk.
Let's say you have this initial payload:
You want to modify a specific element within ArrayPath. So you would write this selector:
And build a config modifier schema with a keyword like this:
These would produce this output payload:
So all items with the same property name would change.
To overwrite an existing value, enter the specific element name without an asterisk (*). If you enter a specific array name, this means that the new value will overwrite the entire array.
For example, let's say you have this initial payload:
You want to overwrite all the values within ArrayPath. So you would write this selector:
And build a config modifier schema with a keyword like this:
These would produce this output payload:
Use the concat keyword to build elements into a new array within a payload.
Let's say you have this initial payload:
You want to build an entirely new array. So you would write this selector:
And build a config modifier schema with a keyword like this:
These would produce this output payload:
Use the concat keyword to add values to an existing array within a payload, while retaining any initial values.
Let's say you have this initial payload:
You want to add new values along with existing values at My.Property. So you would write this selector:
And build a config modifier schema with a keyword like this:
These would produce this output payload:
So you would retain original values while adding new values to the array.
Specify a particular value in an array that should change based on your selector.
Let's say you have this initial payload:
You want to change the id value within the array at My.Property, but you only want to change the value where id is currently equal to specific-id:
And build a config modifier schema with a keyword like this:
These would produce this output payload:
So only one value in an array would change based on the conditions you defined.