fromJson<T> static method

ModelLessArray<T> fromJson<T>(
  1. String jsonString
)

Creates a ModelLessArray from a JSON string. The JSON string should represent a list of objects. Each object in the list is converted to a ModelLess instance and added to the array. If parsing fails, an error message is logged to the console. jsonString The JSON string to parse. Returns a ModelLessArray containing the parsed ModelLess instances.

Implementation

static ModelLessArray<T> fromJson<T>(String jsonString) {
  ModelLessArray<T> arrayApiModels = ModelLessArray();

  try {
    List<dynamic> jsonData = json.decode(jsonString);
    for (var element in jsonData) {
      ModelLess apiModel = ModelLess.fromMap(element);
      arrayApiModels.set(apiModel);
    }
  } on Exception catch (e) {
    Console.write("Error Parsing Data for init an ArrayApiModel: $e");
  }

  return arrayApiModels;
}