Unicode C
Unicode C
Example: Http.GetLastJsonData method
Demonstrates theGetLastJsonData method.
Chilkat Unicode C Downloads
#include <C_CkHttpW.h>
#include <C_CkHttpResponseW.h>
#include <C_CkJsonObjectW.h>
void ChilkatSample(void)
{
BOOL success;
HCkHttpW http;
HCkHttpResponseW resp;
HCkJsonObjectW json;
success = FALSE;
http = CkHttpW_Create();
resp = CkHttpResponseW_Create();
// Only allow TLS 1.2 or better.
CkHttpW_putSslProtocol(http,L"TLS 1.2 or higher");
success = CkHttpW_HttpNoBody(http,L"GET",L"https://google.com/",resp);
if (success == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkHttpResponseW_Dispose(resp);
return;
}
json = CkJsonObjectW_Create();
CkJsonObjectW_putEmitCompact(json,FALSE);
CkHttpW_GetLastJsonData(http,json);
wprintf(L"%s\n",CkJsonObjectW_emit(json));
// Output as of Chilkat v11.1.0
// Additional information may be added as requested or needed in future versions of Chilkat.
// {
// "tls": {
// "params": {
// "sniHostname": "www.google.com",
// "allowConnectionOnlyIfServerChooses": "TLS 1.2 or higher"
// },
// "negotiatedTlsVersion": "TLS 1.3"
// }
// }
CkHttpW_Dispose(http);
CkHttpResponseW_Dispose(resp);
CkJsonObjectW_Dispose(json);
}