def LJSONExporter(landmark_group, file_handle, **kwargs):
    r"""
    Given a file handle to write in to (which should act like a Python `file`
    object), write out the landmark data. No value is returned.

    Writes out the LJSON format which is a verbose format that closely
    resembles the landmark group format. It describes semantic labels and
    connectivity between labels. The first axis of the format represents
    the image y-axis and is consistent with ordering within Menpo.

    Parameters
    ----------
    landmark_group : map:`LandmarkGroup`
        The landmark group to write out.
    file_handle : `file`-like object
        The file to write in to
    """
    lg_json = landmark_group.tojson()
    # Add version string
    lg_json['version'] = 2

    # Convert nan values to None so that json correctly maps them to 'null'
    points = lg_json['landmarks']['points']
    # Flatten list
    try:
        ndim = len(points[0])
    except __HOLE__:
        ndim = 0
    filtered_points = [None if np.isnan(x) else x
                       for x in itertools.chain(*points)]
    # Recreate tuples
    if ndim == 2:
        lg_json['landmarks']['points'] = list(zip(filtered_points[::2],
                                              filtered_points[1::2]))
    elif ndim == 3:
        lg_json['landmarks']['points'] = list(zip(filtered_points[::3],
                                              filtered_points[1::3],
                                              filtered_points[2::3]))
    else:
        lg_json['landmarks']['points'] = []

    return json.dump(lg_json, file_handle, indent=4, separators=(',', ': '),
                     sort_keys=True, allow_nan=False)
dataset/ETHPy150Open menpo/menpo/menpo/io/output/landmark.py/LJSONExporter