def add_data_to_json(json_obj, query_data, candidate_data, joined_data=None):
    """Adds query and candidate datasets to json object.
    """

    json_obj['query_data'] = query_data
    json_obj['candidate_data'] = candidate_data
    if joined_data:
        json_obj['joined_data'] = joined_data
    return json_obj