<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def nfa_to_json(nfa: dict, name: str, path: str = './'):
 """ Exports a NFA to a JSON file. :param dict nfa: NFA to export; :param str name: name of the output file; :param str path: path where to save the JSON file (default: working directory). """

    transitions = list()  # key[state in states, action in alphabet]
    #                       value [Set of arriving states in states]
    for p in nfa['transitions']:
        for dest in nfa['transitions'][p]:
            transitions.append([p[0], p[1], dest])

    out = {
        'alphabet': list(nfa['alphabet']),
        'states': list(nfa['states']),
        'initial_states': list(nfa['initial_states']),
        'accepting_states': list(nfa['accepting_states']),
        'transitions': transitions
    }

    if not os.path.exists(path):
        os.makedirs(path)
    file = open(os.path.join(path, name + '.json'), 'w')
    json.dump(out, file, sort_keys=True, indent=4)
    file.close()