import codecs
import json


def _csv_rec_to_nlj_rec(val):

    """
    Convert a line from `csv.DictReader()` NLJ with `None` instead of empty
    fields.
    """

    val = codecs.decode(val, 'unicode_escape')

    if val == '':
        return None
    elif val.startswith('{'):
        return json.loads(val)
    else:
        return val