@classmethod<EOL><INDENT>def from_json(cls, json_file, json_path=None, key_mapping=None):<DEDENT>
cls._validate_key_mapping(key_mapping)<EOL>with open(json_file, "<STR_LIT:rb>") as f:<EOL><INDENT>data = json.loads(f.read().decode("<STR_LIT:utf-8>"))<EOL>return cls._from_json_data(data, json_path, key_mapping)<EOL><DEDENT>
Load connection credential from json file.

:param json_file: str, path to json file
:param json_path: str, dot notation of the path to the credential dict.
:param key_mapping: dict, map 'host', 'port', 'database', 'username', 'password'
    to custom alias, for example ``{'host': 'h', 'port': 'p', 'database': 'db', 'username': 'user', 'password': 'pwd'}``. This params are used to adapt any json data.

:rtype:
:return:

Example:

Your json file::

    {
        "credentials": {
            "db1": {
                "h": "example.com",
                "p": 1234,
                "db": "test",
                "user": "admin",
                "pwd": "admin",
            },
            "db2": {
                ...
            }
        }
    }

Usage::

    cred = Credential.from_json(
        "path-to-json-file", "credentials.db1",
        dict(host="h", port="p", database="db", username="user", password="pwd")
    )