mirror of
https://github.com/aljazceru/Auto-GPT.git
synced 2025-12-18 14:34:23 +01:00
Refactor SkillNodeData model for robust JSON deserialization
This commit updates the SkillNodeData class to handle optional or missing JSON fields more robustly. Now, the model provides default values for each field, ensuring that the object can be instantiated successfully even if some JSON fields are missing or set to null.
This commit is contained in:
@@ -22,13 +22,13 @@ class SkillNodeData {
|
|||||||
|
|
||||||
factory SkillNodeData.fromJson(Map<String, dynamic> json) {
|
factory SkillNodeData.fromJson(Map<String, dynamic> json) {
|
||||||
return SkillNodeData(
|
return SkillNodeData(
|
||||||
name: json['name'],
|
name: json['name'] ?? "",
|
||||||
category: List<String>.from(json['category']),
|
category: List<String>.from(json['category'] ?? []),
|
||||||
task: json['task'],
|
task: json['task'] ?? "",
|
||||||
dependencies: List<String>.from(json['dependencies']),
|
dependencies: List<String>.from(json['dependencies'] ?? []),
|
||||||
cutoff: json['cutoff'],
|
cutoff: json['cutoff'] ?? 0,
|
||||||
ground: Ground.fromJson(json['ground']),
|
ground: Ground.fromJson(json['ground'] ?? {}),
|
||||||
info: Info.fromJson(json['info']),
|
info: Info.fromJson(json['info'] ?? {}),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user