import yaml
import json


def get_json_data_from_file(filename):
    """Return json object from a json or yaml file"""
    if filename.lower().endswith(".yaml"):
        with open(filename, "rb") as fp:
            yaml_data = fp.read()
            # io.BytesIO(json.dumps(yaml.load(yaml_data, Loader=yaml.FullLoader)).encode())
            return yaml.load(yaml_data, Loader=yaml.FullLoader)
    else:
        with open(filename, "r") as f:
            return json.load(f)