Sample code for 30+ languages & platforms
DataFlex

JSON Parsing with Sample Data for a Merchant/Payment Transaction

See more JSON Examples

Demonstrates how to load the following JSON into a JSON object and access the values for this document:
{
"id":"8a829449561d9dcb01571dbee3b275b1",
"paymentType":"DB",
"paymentBrand":"VISA",
"amount":"156.00",
"currency":"EUR",
"merchantTransactionId":"E8A39B31-6FA3-4014-A195-3074DF5BF7A1",
"result":{
	"code":"000.100.110",
	"description":"Request successfully processed in 'Merchant in Integrator Test Mode'"
},
"resultDetails":{
	"ConnectorTxID3":"12311312",
	"ConnectorTxID1":"717473"
},
"card":{
	"bin":"420000",
	"last4Digits":"0000",
	"holder":"Andreas",
	"expiryMonth":"12",
	"expiryYear":"2018"
},
"risk":{
	"score":"100"
},
"buildNumber":"4b471ea5366e5e9c9a21392a39769f8d7b40b4e8@2016-09-08 13:31:54 +0000",
"timestamp":"2016-09-12 09:33:52+0000",
}

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoJson
    String sTemp1

    Move False To iSuccess

    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End

    // Load the JSON into the object.
    // Call json.Load to load from a string rather than a file...
    Get ComLoadFile Of hoJson "qa_data/json/merchantPayment.json" To iSuccess
    // We are assuming success..

    // Get the easy stuff:
    Get ComStringOf Of hoJson "id" To sTemp1
    Showln "id: " sTemp1
    Get ComStringOf Of hoJson "paymentType" To sTemp1
    Showln "paymentType: " sTemp1
    Get ComStringOf Of hoJson "currency" To sTemp1
    Showln "currency: " sTemp1
    Get ComStringOf Of hoJson "buildNumber" To sTemp1
    Showln "buildNumber: " sTemp1

    // Get information that's nested within a sub-object:
    Get ComStringOf Of hoJson "result.code" To sTemp1
    Showln "result: code: " sTemp1
    Get ComStringOf Of hoJson "result.description" To sTemp1
    Showln "result: description: " sTemp1

    Get ComStringOf Of hoJson "card.bin" To sTemp1
    Showln "card: bin: " sTemp1
    Get ComStringOf Of hoJson "card.last4Digits" To sTemp1
    Showln "card: last4Digits: " sTemp1


End_Procedure