import json


def load_from_json(file_path):

    """
    Loading data from a json file.
    Input: 
        file_path: (the source file)
    Output:
        data: the loaded data
    """

    # catching possible pathlib.Path object
    if isinstance(file_path, str) is False:
        file_path = str(file_path)

    # checking if file_path is a json file
    assert file_path.endswith('.json'), 'Given file_path is invalid for saving into json file'

    with open(file_path, 'r') as infile:
        data = json.load(infile)

    return data