def raw_to_dict(obj):
    """Convert an object holding raw analysis results into a dictionary. This
    is meant for JSON dumping."""
    result = {}
    for a in obj._fields:
        v = getattr(obj, a, None)
        if v is not None:
            result[a] = v
    return result
