-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Description
Add two utility methods with the following signature to the shared API:
def getInnerValue(def data, String path); // default delimiter of '.'
def getInnerValue(def data, String path, String delimiter);
This method should take in either a Map or a List and be able to parse a path to get a value out of the data. The path should be separated into pieces based on the delimiter. For each piece in the path if the current level is a Map retrieve the value based on the piece as a key, if the current level is a List retrieve the value based on the piece as an index.
Example:
String path = "key0.2.key1";
def value = getInnerValue(data, path);
This assumes a structure of Map, List, Map and will return the equivalent of data.get('key0').get(2).get('key1');
This allows uses to specify a path as part of params and then use this method without having to separate the path themselves. This is useful in many situations when the context contains _source as there can be many inner fields.