def METHOD_NAME(ofit, exportCharges, callback):
    # A few notes:
    # max fit name length is 50 characters
    # Most keys are created simply because they are required, but bogus data is okay
    nested_dict = lambda: defaultdict(nested_dict)
    fit = nested_dict()
    sFit = svcFit.getInstance()
    # max length is 50 characters
    name = ofit.name[:47] + '...' if len(ofit.name) > 50 else ofit.name
    fit['name'] = name
    fit['ship_type_id'] = ofit.ship.item.ID
    # 2017/03/29 NOTE: "<" or "&lt;" is Ignored
    # fit['description'] = "<pyfa:%d />" % ofit.ID
    fit['description'] = "" if ofit.notes is None else ofit.notes[:397] + '...' if len(ofit.notes) > 400 else ofit.notes
    fit['items'] = []
    slotNum = {}
    charges = {}
    for module in ofit.modules:
        if module.isEmpty:
            continue
        item = nested_dict()
        slot = module.slot
        if slot == FittingSlot.SUBSYSTEM:
            # Order of subsystem matters based on this attr. See GH issue #130
            slot = int(module.getModifiedItemAttr("subSystemSlot"))
            item['flag'] = slot
        else:
            if slot not in slotNum:
                slotNum[slot] = INV_FLAGS[slot]
            item['flag'] = slotNum[slot]
            slotNum[slot] += 1
        item['quantity'] = 1
        item['type_id'] = module.item.ID
        fit['items'].append(item)
        if module.charge and exportCharges:
            if module.chargeID not in charges:
                charges[module.chargeID] = 0
            # `or 1` because some charges (ie scripts) are without qty
            charges[module.chargeID] += module.numCharges or 1
    for cargo in ofit.cargo:
        item = nested_dict()
        item['flag'] = INV_FLAG_CARGOBAY
        item['quantity'] = cargo.amount
        item['type_id'] = cargo.item.ID
        fit['items'].append(item)
    for chargeID, amount in list(charges.items()):
        item = nested_dict()
        item['flag'] = INV_FLAG_CARGOBAY
        item['quantity'] = amount
        item['type_id'] = chargeID
        fit['items'].append(item)
    for drone in ofit.drones:
        item = nested_dict()
        item['flag'] = INV_FLAG_DRONEBAY
        item['quantity'] = drone.amount
        item['type_id'] = drone.item.ID
        fit['items'].append(item)
    for fighter in ofit.fighters:
        item = nested_dict()
        item['flag'] = INV_FLAG_FIGHTER
        item['quantity'] = fighter.amount
        item['type_id'] = fighter.item.ID
        fit['items'].append(item)
    if len(fit['items']) == 0:
        raise ESIExportException("Cannot export fitting: module list cannot be empty.")
    text = json.dumps(fit)
    if callback:
        callback(text)
    else:
        return text