tryJson<T> static method

ModelLessArray<T>? tryJson<T>(
  1. String jsonString
)

Implementation

static ModelLessArray<T>? tryJson<T>(String jsonString) {
  try {
    List<dynamic> jsonData = json.decode(jsonString);
    ModelLessArray<T> arrayApiModels = ModelLessArray();
    for (var element in jsonData) {
      ModelLess apiModel = ModelLess.fromMap(element);
      arrayApiModels.set(apiModel);
    }
    return arrayApiModels;
  } catch (e) {
    return null;
  }
}