Powered by Zoomin Software. For more details please contactZoomin

Develop with FastTrack

Referencing values in data with PathConfig

  • Last Updated: May 5, 2026
  • 3 minute read
    • MarkLogic Server
    • Documentation

FastTrack widgets use a common method for referencing values in data -- a PathConfig object. In its simplest form, PathConfig includes a path property that references a value in the data using a JSONPath string. FastTrack uses the jsonpath-plus library as its underlying JSONPath implementation.

<MyWidget
  data={{ result: { prop1: "Mark", prop2: "Logic", prop3: ["fast", "track"] }}} // Data
  config={{ path: "result.prop2" }} // PathConfig object that references a value ("logic") in the data
/>

In this example, the config prop takes a PathConfig object. The path value in the PathConfig object references “Logic” in the data object.

An alternative to using the path property is using the paths property (for referencing multiple values) and the value property (for providing a static value). The referenced value(s) can be transformed by setting additional properties in the PathConfig object. See the API table and examples for the available properties and how the transformations are applied.

Path Config API

PathConfig Property Name Type Example Description
path string "result.prop2" A JSONPath string that references a value.
paths string[] [ "result.prop1", "result.prop2" ] An array of one or more JSONPath strings that reference one or more values, which are returned as an array.
value any "fasttrack" A static value that is used as the referenced value. This is an alternative to referencing values with path or paths.
regex RegExp /[ft].?/ A regular expression that is applied to the referenced value using the match() method. The first matched value in the match() array is returned. (If no match is found, the referenced value is left unchanged.)
dictionary Object { fast: "faster", track: "tracker" } A dictionary object of key/value pairs. The referenced value is used as a key in the dictionary and the matching value is returned. (If the key does not exist, undefined is returned.)
transform function (val) => return val.toUpperCase() A function that takes the referenced value and returns a transformed value.
separator string ", " A separator string that is applied to a referenced array of strings. The array of strings is joined with the separator value.
prefix string "Mr." A string prefix prepended to the referenced value.
suffix string ", Jr." A string suffix appended to the referenced value.
nilValue any “Not found” Value to use for referenced values that are undefined or null (arrays are ignored).

If multiple transformation properties are provided in PathConfig, the transformations are executed in the following order:

  1. regex
  2. dictionary
  3. transform
  4. separator
  5. prefix
  6. suffix

Examples

The examples show how to reference and then transform values in data using PathConfig.

Apply a regular expression

<MyWidget
  data={{ result: { prop1: "Mark", prop2: "Logic", prop3: ["fast", "track"] }}}
  config={{ 
    path: "result.prop3[0]",
    regex: /[fqz].?/
  }}
/>

This above configuration returns “fa”.

Apply a dictionary

<MyWidget
  data={{ result: { prop1: "Mark", prop2: "Logic", prop3: ["fast", "track"] }}}
  config={{ 
    path: "result.prop3[1]",
    dictionary: {{ fast: "quick", track: "trick" }}
  }}
/>

The above configuration returns “trick”.

Apply a transform function

<MyWidget
  data={{ result: { prop1: "Mark", prop2: "Logic", prop3: ["fast", "track"] }}}
  config={{ 
    path: "result.prop2",
    transform: (val) => return val.toUpperCase()
  }}
/>

The above configuration returns “LOGIC”.

Join an array with a separator

<MyWidget
  data={{ result: { prop1: "Mark", prop2: "Logic", prop3: ["fast", "track"] }}}
  config={{ 
    path: "result.prop3",
    separator: " + "
  }}
/>

The above configuration returns “fast + track”.

Add a prefix

MyWidget
  data={{ result: { prop1: "Mark", prop2: "Logic", prop3: ["fast", "track"] }}}
  config={{ 
    path: "result.prop1",
    prefix: "Mr. "
  }}
/>

The above configuration returns “Mr. Mark”.

Add a suffix

<MyWidget
  data={{ result: { prop1: "Mark", prop2: "Logic", prop3: ["fast", "track"] }}}
  config={{ 
    path: "result.prop1",
    suffix: ", Jr."
  }}
/>

The above configuration returns “Mark, Jr.”.

Apply multiple transformations

<MyWidget
  data={{ result: { prop1: "ml", prop2: "ft" }}}
  config={{ 
    path: "result.prop2",
    regex: /[fqz].?/,
    dictionary: {{ ml: "Mark Logic", ft: "Fast Track" }},
    transform: (val) => return val.replace(' ', ''),
    prefix: "Hello, ",
    suffix: "!"
  }}
/>

The above configuration returns “Hello, FastTrack!”.

Get multiple values as an array

<MyWidget
  data={{ result: { prop1: "Mark", prop2: "Logic", prop3: ["fast", "track"] }}}
  config={{ 
    paths: [ "result.prop2", "result.prop3[1]" ]
  }}
/>

The above configuration returns [“Logic”, “fast”].

Use a value

<MyWidget
  data={{ result: { prop1: "Mark", prop2: "Logic", prop3: ["fast", "track"] }}}
  config={{ 
    value: "default"
  }}
/>

The above configuration returns “default”. Nothing in the data object is referenced.

TitleResults for “How to create a CRG?”Also Available inAlert