getByPath<T> method

T getByPath<T>(
  1. JsonPath path
)
override

Implementation

T getByPath<T>(JsonPath path) {
  dynamic value = this;
  for (var segment in path.segments) {
    if (value is MBaseModel) {
      value = value[segment];
    } else if (value is Map) {
      value = value[segment];
    } else {
      throw Exception("Illegal path: $path at segment $segment.  Expected Map or MBaseModel but found ${value.runtimeType}");
    }
    if (value == null) {
      return null as T;
    }
  }
  return value as T;
}