V2TimFriendInfo.fromJson constructor

V2TimFriendInfo.fromJson(
  1. Map json
)

Implementation

V2TimFriendInfo.fromJson(Map json) {
  json = Utils.formatJson(json);
  userID = json['friend_profile_identifier'] ?? "";
  friendRemark = json['friend_profile_remark'];
  friendGroups = json['friend_profile_group_name_array']?.cast<String>();

  var customInfoList = List<Map<String, dynamic>>.from(json['friend_profile_custom_string_array'] ?? []);
  // C 接口在获取时没有去掉 "Tag_SNS_Custom_" 前缀。
  customInfoList = customInfoList.map((item) {
    final key = item['friend_profile_custom_string_info_key'] as String?;
    if (key != null && key.startsWith('Tag_SNS_Custom_')) {
      return {
        'friend_profile_custom_string_info_key': key.replaceFirst('Tag_SNS_Custom_', ''),
        'friend_profile_custom_string_info_value': item['friend_profile_custom_string_info_value']
      };
    }
    return item;
  }).toList();
  friendCustomInfo = Tools.jsonList2Map<String>(customInfoList, 'friend_profile_custom_string_info_key', 'friend_profile_custom_string_info_value');

  userProfile = json['friend_profile_user_profile'] != null
      ? V2TimUserFullInfo.fromJson(json['friend_profile_user_profile'])
      : null;
}