class ExercisePlanTemplate { int exercisePlanTemplateId; String name; String description; String templateType; String nameTranslation; String descriptionTranslation; List exerciseTypes = List(); ExercisePlanTemplate.fromJson(Map json) { this.exercisePlanTemplateId = json['exercisePlanId']; this.name = json['name']; this.description = json['description']; this.templateType = json['templateType']; this.nameTranslation = json['translations'] != null && (json['translations']).length > 0 ? json['translations'][0]['name'] : this.name; this.descriptionTranslation = json['translations'] != null && (json['translations']).length > 0 ? json['translations'][0]['description'] : this.description; if (json['details'] != null && (json['details']).length > 0) { List details = json['details']; details.forEach((element) { exerciseTypes.add(element['exerciseTypeId']); }); } } Map toJson() { return { "exercisePlanTemplateId": exercisePlanTemplateId, "name": name, "description": "description", "templateType": templateType, "nameTranslation": nameTranslation, "descriptionTranslation": descriptionTranslation, "exerciseTypes": exerciseTypes.toString() }; } }