j = json.load(open('json_file_above.json'))
a = j['array']
d = {x['id']: x for x in a}
for x in a:
    x['subcats'] = [dict(id=i, name=d[i]['name'], parent_id=d[i][
        'parent_id']) for i in [y for y in x['path_info'][1:]]]
del x['path_info']
Create hierarchical json dump from list of dictionary in python