lookup method

dynamic lookup(
  1. String path
)

Searches for a given path in the map.

Implementation

dynamic lookup(String path) {
  var data = this;
  final keys = path.trim().split(' ');
  for (final entry in keys.asMap().entries) {
    final isLastKey = entry.key == keys.length - 1;
    final key = entry.value;
    final value = data[key];
    if (!isLastKey && value is JsonMap) {
      data = value;
      continue;
    }
    return value;
  }
}