convertUserFromJson static method

User convertUserFromJson(
  1. String json
)

// converts User List Json to List

Implementation

// static List<User> convertUsersFromJson(String userJson) {
//   try {
//     List<dynamic> jsonData = jsonDecode(userJson);
//     return jsonData.map((user) => User.fromJson(user)).toList();
//   } on FormatException {
//     throw CustomFormatException(
//         message:
//             '\n that is the wrong format for User: \n $userJson \n right String format:\n [{"userId":"value","firstName":"value", "lastName":"value", "role":{"roleId":"value", "name":"value"}}] \n Note: ids are optional');
//   }
// }

/// convert from UserJson  to User
static User convertUserFromJson(String json) {
  try {
    var jsonData = jsonDecode(json);
    return User.fromJson(jsonData);
  } on FormatException {
    throw CustomFormatException(
        message:
            '\n that is the wrong format for User: \n $json \n right String format:\n {"userId":"value","userName":"value", "language":"value", "owner":"value","termsAndConditions":{}, "consent":{} } \n Note: ids are optional');
  }
}