Visual FoxPro
Visual FoxPro
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 Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loJson
LOCAL loSb
LOCAL loBd
lnSuccess = 0
loJson = CreateObject('Chilkat.JsonObject')
* Load the JSON.
lnSuccess = loJson.LoadFile("qa_data/json/JSR5U.json")
IF (lnSuccess <> 1) THEN
? loJson.LastErrorText
RELEASE loJson
CANCEL
ENDIF
* The JSON we loaded contains this:
* {
* ...
* ...
* "data": {
* "content": "JVBERi0xLjQ..."
* }
* ...
* ...
* }
loSb = CreateObject('Chilkat.StringBuilder')
loJson.StringOfSb("data.content",loSb)
loBd = CreateObject('Chilkat.BinData')
loBd.AppendEncodedSb(loSb,"base64")
lnSuccess = loBd.WriteFile("qa_output/a0015.pdf")
RELEASE loJson
RELEASE loSb
RELEASE loBd