Unicode C++
Unicode C++
Extract PDF from JSON
See more JSON Examples
Demonstrates how to extract a PDF file contained within JSON. The file is represented as a base64 string within the JSON. Note: This example can extract any type of file, not just a PDF file.Chilkat Unicode C++ Downloads
#include <CkJsonObjectW.h>
#include <CkStringBuilderW.h>
#include <CkBinDataW.h>
void ChilkatSample(void)
{
bool success = false;
CkJsonObjectW json;
// Load the JSON.
success = json.LoadFile(L"qa_data/json/JSR5U.json");
if (success != true) {
wprintf(L"%s\n",json.lastErrorText());
return;
}
// The JSON we loaded contains this:
// {
// ...
// ...
// "data": {
// "content": "JVBERi0xLjQ..."
// }
// ...
// ...
// }
CkStringBuilderW sb;
json.StringOfSb(L"data.content",sb);
CkBinDataW bd;
bd.AppendEncodedSb(sb,L"base64");
success = bd.WriteFile(L"qa_output/a0015.pdf");
}