api.array :users do @users.each do |user| api.user do api.id user.id api.login user.login api.firstname user.firstname api.lastname user.lastname api.mail user.mail api.created_on user.created_on api.last_login_on user.last_login_on api.array :custom_fields do user.visible_custom_field_values.each do |custom_value| api.custom_field custom_value.value, :id => custom_value.custom_field_id, :name => custom_value.custom_field.name end end unless user.visible_custom_field_values.empty? end end end