Repository: pydantic/pydantic

Issue:
An empty string is a valid JSON attribute name
### Checks

* [ x] I added a descriptive title to this issue
* [ x] I have searched (google, github) for similar issues and couldn't find anything
* [ x] I have read and followed [the docs](https://pydantic-docs.helpmanual.io/) and still think this is a bug

# Bug

Output of `python -c "import pydantic.utils; print(pydantic.utils.version_info())"`:
```
             pydantic version: 1.9.0
            pydantic compiled: False
                 install path: /Users/s_tsaplin/projects/github.com/sergeytsaplin/pydantic/pydantic
               python version: 3.9.13 (main, May 19 2022, 14:10:54)  [Clang 13.1.6 (clang-1316.0.21.2)]
                     platform: macOS-12.4-x86_64-i386-64bit
     optional deps. installed: ['devtools', 'dotenv', 'email-validator', 'typing-extensions']
```

```py
from pydantic import BaseModel, Field

class Model(BaseModel):
        empty_string_key: int = Field(alias='')

data = {'': 123}
m = Model(**data)
m.dict(by_alias=True)
```

## Current behavior:

The code causes the exception:

```
Traceback (most recent call last):
  File "<masked>/.pyenv/versions/3.10.1/lib/python3.10/code.py", line 90, in runcode
    exec(code, self.locals)
  File "<input>", line 1, in <module>
  File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for Model
empty_string_key
  field required (type=value_error.missing)
 ```

## Expected result:

The code should print:

```
{'': 123}
```

Links:
* https://stackoverflow.com/questions/58916957/is-an-empty-string-a-valid-json-key
* https://datatracker.ietf.org/doc/html/rfc6901#section-5


Discussion:

Resolving patch:
diff --git a/pydantic/fields.py b/pydantic/fields.py
--- a/pydantic/fields.py
+++ b/pydantic/fields.py
@@ -148,7 +148,7 @@ def __init__(self, default: Any = Undefined, **kwargs: Any) -> None:
         self.default = default
         self.default_factory = kwargs.pop('default_factory', None)
         self.alias = kwargs.pop('alias', None)
-        self.alias_priority = kwargs.pop('alias_priority', 2 if self.alias else None)
+        self.alias_priority = kwargs.pop('alias_priority', 2 if self.alias is not None else None)
         self.title = kwargs.pop('title', None)
         self.description = kwargs.pop('description', None)
         self.exclude = kwargs.pop('exclude', None)
@@ -394,8 +394,8 @@ def __init__(
     ) -> None:
 
         self.name: str = name
-        self.has_alias: bool = bool(alias)
-        self.alias: str = alias or name
+        self.has_alias: bool = alias is not None
+        self.alias: str = alias if alias is not None else name
         self.type_: Any = convert_generics(type_)
         self.outer_type_: Any = type_
         self.class_validators = class_validators or {}


Test patch:
diff --git a/tests/test_aliases.py b/tests/test_aliases.py
--- a/tests/test_aliases.py
+++ b/tests/test_aliases.py
@@ -335,3 +335,13 @@ def alias_generator(x):
         'd_config_parent',
         'e_generator_child',
     ]
+
+
+def test_empty_string_alias():
+    class Model(BaseModel):
+        empty_string_key: int = Field(alias='')
+
+    data = {'': 123}
+    m = Model(**data)
+    assert m.empty_string_key == 123
+    assert m.dict(by_alias=True) == data