FILTERING AN ARRAY IRREGARDLESS OF THE ARRANGEMNT (Python)

Am trying to save this data from a callback url but the arrangement keeps changing, how do I fetch the data without use of index

{"Body":{
    "stkCallback":{
        "MerchantRequestID":"106225-49293961-1",
        "CheckoutRequestID":"ws_CO_041120220958559137xxxxx768",
        "ResultCode":0,
        "ResultDesc":"The service request is processed successfully.",
        "CallbackMetadata":{
            "Item":[
                {"Name":"Amount","Value":1.00},
                {"Name":"MpesaReceiptNumber","Value":"QK438EQIOX"},
                {"Name":"TransactionDate","Value":20221104095914},
                {"Name":"PhoneNumber","Value":2547xxxxx178}
                ]
            }
        }
    }
}

This is what I have done

merchant_requestID = mpesa_body["Body"]["stkCallback"]["MerchantRequestID"]
print(merchant_requestID)
checkout_requestID = mpesa_body["Body"]["stkCallback"]["CheckoutRequestID"]
print(checkout_requestID)
result_code = mpesa_body["Body"]["stkCallback"]["ResultCode"]
print(result_code)
result_desc = mpesa_body["Body"]["stkCallback"]["ResultDesc"]
print(result_desc)
amount = mpesa_body["Body"]["stkCallback"]["CallbackMetadata"]["Item"][0]["Value"]
print(amount)
mpesa_receipt_number = mpesa_body["Body"]["stkCallback"]["CallbackMetadata"]["Item"][1]["Value"]
print(mpesa_receipt_number)
transaction_date = mpesa_body["Body"]["stkCallback"]["CallbackMetadata"]["Item"][2]["Value"]
print(transaction_date)
phone_number = mpesa_body["Body"]["stkCallback"]["CallbackMetadata"]["Item"][3]["Value"]
print(phone_number)
balance = ''

Some transaction will have balance other will not have and that is where the error comes in because of fetching the data using index.

Advice on how to save the data, more so the Item list without use of index.

Back to Top