import gzip
import json


def load_json(filename):
    """ Load JSON from text file or gzip """
    if filename.endswith("gz"):
        f = gzip.open(filename, "rt")
    else:
        f = open(filename, "rt")
    return json.load(f)