pythonuuid

python: how to convert a valid uuid from String to UUID?


I receive the data as

   {
        "name": "Unknown",
        "parent": "Uncategorized",
        "uuid": "06335e84-2872-4914-8c5d-3ed07d2a2f16"
    },

and I need to convert the uuid from String to uuid

I did not find a way on the python docs, or am I missing something basic here?


Solution

  • Just pass it to uuid.UUID:

    import uuid
    
    o = {
        "name": "Unknown",
        "parent": "Uncategorized",
        "uuid": "06335e84-2872-4914-8c5d-3ed07d2a2f16"
    }
    
    print uuid.UUID(o['uuid']).hex