class KRNodeGroupList {
  final List<KRNodeGroupListItem> list;

  const KRNodeGroupList({required this.list});

  factory KRNodeGroupList.fromJson(Map<String, dynamic> json) {
    final dynamic listData = json['list'];
    if (listData == null) return KRNodeGroupList(list: []);
    
    try {
      return KRNodeGroupList(
        list: (listData as List)
            .map((e) => KRNodeGroupListItem.fromJson(e))
            .toList(),
      );
    } catch (e) {
      return KRNodeGroupList(list: []);
    }
  }
}

class KRNodeGroupListItem {
  final String id;
  final String name;
  final String icon;

  const KRNodeGroupListItem({
    required this.id,
    required this.name,
    required this.icon,
  });

  factory KRNodeGroupListItem.fromJson(Map<String, dynamic> json) {
    return KRNodeGroupListItem(
      id: json['id']?.toString() ?? '',
      name: json['name']?.toString() ?? '',
      icon: json['icon']?.toString() ?? '',
    );
  }
}
