From 18f202d3e461780dfc14c8b11e569a841191b6ee Mon Sep 17 00:00:00 2001 From: Neeraj Gupta <254676+ua741@users.noreply.github.com> Date: Fri, 5 Apr 2024 14:37:59 +0530 Subject: [PATCH] [mob] Fixed bug in parsing json --- mobile/lib/face/model/person.dart | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/mobile/lib/face/model/person.dart b/mobile/lib/face/model/person.dart index 10e1c77bfa..ee1cb724b2 100644 --- a/mobile/lib/face/model/person.dart +++ b/mobile/lib/face/model/person.dart @@ -39,7 +39,7 @@ class ClusterInfo { factory ClusterInfo.fromJson(Map json) { return ClusterInfo( id: json['id'] as int, - faces: Set.from(json['faces'] as List), + faces: (json['faces'] as List).map((e) => e as String).toSet(), ); } } @@ -92,18 +92,21 @@ class PersonData { // fromJson factory PersonData.fromJson(Map json) { + final assigned = (json['assigned'] == null || json['assigned'].length == 0) + ? [] + : List.from( + json['assigned'].map((x) => ClusterInfo.fromJson(x)), + ); + + final rejected = (json['rejected'] == null || json['rejected'].length == 0) + ? [] + : List.from( + json['rejected'].map((x) => ClusterInfo.fromJson(x)), + ); return PersonData( name: json['name'] as String, - assigned: List.from( - (json['assigned'] as List?) - ?.map((e) => ClusterInfo.fromJson(e)) ?? - List.empty(), - ), - rejected: List.from( - (json['rejected'] as List?) - ?.map((e) => ClusterInfo.fromJson(e)) ?? - List.empty(), - ), + assigned: assigned, + rejected: rejected, avatarFaceId: json['avatarFaceId'] as String?, isHidden: json['isHidden'] as bool? ?? false, birthDate: json['birthDate'] as String?,