convertJsonFromGet method

  1. @visibleForOverriding
dynamic convertJsonFromGet(
  1. String json,
  2. String? key
)

If a key is defined from the adapter and it is not null in the response, use it to narrow the response. Otherwise, if there is only one top level key, use it to narrow the response. Otherwise, return the payload.

Implementation

@visibleForOverriding
dynamic convertJsonFromGet(String json, String? key) {
  final decoded = jsonDecode(json);
  if (key != null && decoded[key] != null) {
    return decoded[key];
  } else if (decoded is Map) {
    if (decoded.keys.length == 1) {
      return decoded.values.first;
    }
  }

  return decoded;
}