deserialize method

dynamic deserialize(
  1. String jsonVal,
  2. String targetType
)

Deserialize the response into the target type.

Implementation

dynamic deserialize(String jsonVal, String targetType) {
  // Remove all spaces.  Necessary for reg expressions as well.
  targetType = targetType.replaceAll(' ', '');

  if (targetType == 'String') {
    return jsonVal;
  }

  final decodedJson = json.decode(jsonVal);
  return _deserialize(decodedJson, targetType);
}