Chilkat HOME Android™ Classic ASP C C++ C# Mono C# .NET Core C# C# UWP/WinRT DataFlex Delphi ActiveX Delphi DLL Visual FoxPro Java Lianja MFC Objective-C Perl PHP ActiveX PHP Extension PowerBuilder PowerShell PureBasic CkPython Chilkat2-Python Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ Visual Basic 6.0 VB.NET VB.NET UWP/WinRT VBScript Xojo Plugin Node.js Excel Go
(MFC) JSON Parsing with Sample Data for a Merchant/Payment TransactionDemonstrates 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",
}
#include <CkJsonObject.h> void ChilkatSample(void) { CkString strOut; CkJsonObject json; // Load the JSON into the object. // Call json.Load to load from a string rather than a file... bool success = json.LoadFile("qa_data/json/merchantPayment.json"); // We are assuming success.. // Get the easy stuff: strOut.append("id: "); strOut.append(json.stringOf("id")); strOut.append("\r\n"); strOut.append("paymentType: "); strOut.append(json.stringOf("paymentType")); strOut.append("\r\n"); strOut.append("currency: "); strOut.append(json.stringOf("currency")); strOut.append("\r\n"); strOut.append("buildNumber: "); strOut.append(json.stringOf("buildNumber")); strOut.append("\r\n"); // Get information that's nested within a sub-object: strOut.append("result: code: "); strOut.append(json.stringOf("result.code")); strOut.append("\r\n"); strOut.append("result: description: "); strOut.append(json.stringOf("result.description")); strOut.append("\r\n"); strOut.append("card: bin: "); strOut.append(json.stringOf("card.bin")); strOut.append("\r\n"); strOut.append("card: last4Digits: "); strOut.append(json.stringOf("card.last4Digits")); strOut.append("\r\n"); SetDlgItemText(IDC_EDIT1,strOut.getUnicode()); } |
||||
© 2000-2022 Chilkat Software, Inc. All Rights Reserved.