getByPath static method
Implementation
static dynamic getByPath(map, JsonPath path) {
dynamic value = map;
for (var segment in path.segments) {
if (value is MapModel) {
value = value[segment];
} else if (value is Map) {
value = value[segment];
} else {
throw Exception("Illegal path: $path at segment $segment. Expected Map or MModel but found ${value.runtimeType}");
}
if (value == null) {
return null;
}
}
return value;
}