Index By
This function is designed for a common API pattern, where a service returns a list of field values as a list of objects which each contain a field name as one key, and a field value as another key.
In that case, this function can be useful in converting that list into an object that contains each field as a key-value pair. Index By solves this problem by letting you specify a keyPath and a valuePath. For each item in the list, the function creates a new key-value pair in the output object.
For example, if you have this list:
[{"fieldname":"x","myvalue":"one"},{"fieldname":"y","myvalue":"two"},{"fieldname":"z","myvalue":"three"}]
and use Index By with keyPath="fieldname" and valuePath="myvalue" then it would output the following object:
Input Fields
-
list(list of objects): a list of objects
-
keyPath(text): the key in the object that has the key names ("fieldname" in the above example)
-
valuePath(text): the key that contains the values ("myvalue" in the above example)
Output Fields
- output(object): an object containing the key/value pairs defined by the input list