Parse Json to fill some text boxes

I am using ChatGPT in Xojo to extract some fields from an Invoice.
I want to parse the json that is returned so that I can fill some text boxes.
Can someone show me some code to parse this?

{
"invoice_number": "274619",
"invoice_date": "10/30/24",
"due_date": "11/14/24",
"company_name": "Anyname Acceptance",
"total_amount": "377.25",
"tax_amount": "1.00",
"po_number": "02396000"
}

Assuming the text is in a variable we’ll call json, something like this:

var jsonDict as Dictionary = ParseJSON( json )

var invoiceNumber as string = jsonDict.Value( "invoice_number" )
var totalAmount as double = jsonDict.Value( "total_amount" )
// etc.
2 Likes

Thanks Kem
I was doing something very simular but was getting an error. I figured out that ChatGPT was adding some extra characters to the beginning and end of the json response. I told chatGPT to not add any extra characters to the response and now it works. Thanks