getJsonField function

dynamic getJsonField(
  1. dynamic response,
  2. String jsonPath
)

Implementation

dynamic getJsonField(dynamic response, String jsonPath) {
  final field = JsonPath(jsonPath).read(response);
  return field.isNotEmpty
      ? field.length > 1
          ? field.map((f) => f.value).toList()
          : field.first.value
      : null;
}