@classmethod
def from_json(cls, filename, key='data', dims=None, edges=None, **kwargs):
    """
        Initialize a BinnedStatistic from a JSON file.

        The JSON file should contain a dictionary, where the data to load is stored
        as the ``key`` entry, with an ``edges`` entry specifying bin edges, and
        optionally, a ``attrs`` entry giving a dict of meta-data

        .. note::
            This uses :class:`nbodykit.utils.JSONDecoder` to load the
            JSON file

        Parameters
        ----------
        filename : str
            the name of the file to load
        key : str, optional
            the name of the key in the JSON file holding the data to load
        dims : list, optional
            list of names specifying the dimensions, i.e., ``['k']`` or ``['k', 'mu']``;
            must be supplied if not given in the JSON file

        Returns
        -------
        dset : BinnedStatistic
            the BinnedStatistic holding the data from file
        """
    import json
    from nbodykit.utils import JSONDecoder
    with open(filename, 'r') as ff:
        state = json.load(ff, cls=JSONDecoder)
    if key not in state:
        args = key, tuple(state.keys())
        raise ValueError(
            "no data entry found in JSON format for '%s' key; valid keys are %s"
             % args)
    data = state[key]
    dims = state.pop('dims', dims)
    if dims is None:
        raise ValueError(
            'no `dims` found in JSON file; please specify as keyword argument')
    edges = state.pop('edges', edges)
    if edges is None:
        raise ValueError(
            'no `edges` found in JSON file; please specify as keyword argument'
            )
    coords = state.pop('coords', None)
    attrs = state.pop('attrs', {})
    attrs.update(kwargs)
    return cls(dims, edges, data, coords=coords, **attrs)
