for k, v in list(data.items()):
    if isinstance(v, int):
        _data[k] = hex(v)
else:
    _data[k] = v
return json.dumps(_data, indent=4)
if __name__ == '__main__':
    data = {'a': 1, 'b': 2.0, 'c': 3}
print(serialize(data))
How to print integers as hex strings using json.dumps() in Python