Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I am using Qlikview 12
I have a request to have Qlik produce JSON as an output. I was trying to look online at the API guide, but it hasn't been updated in a while. I don't need the actual way HOW to do it right now, but IS it possible to produce a JSON file with the API's?
thanks
Frank
I don't think that's supported by the API.
You might consider exporting your data to csv and then converting to JSON.
Hi Frank,
What are you doing with the JSON file ?
If you are using it to send the data to a webservice this can be done using an Extension with javascript.
This post might help:
https://community.qlikview.com/thread/50694
Let me know and see if I can find some examples.
Thanks
Mark
Mark
The client wants to use their own visualization. So all they really want to use is the Qlik engine.
Regards,
Frank
Hi Frank,
Does your data model need to contain the JSON or do you need to export the JSON to a file ?
Mark
Mark
I need to export.
Hi Frank,
If you are using Ajax you could still create an extension send the data elsewhere and changing this to json is possible:
OR you could look into macros and building the format manually:
Have you looked into trying the macro route to format the text file manually :
sub exportrequest
Set fso = CreateObject("Scripting.FileSystemObject" )
Set file = fso.CreateTextFile("C:\testjson.txt",True)
file.Write("testtext")
end sub
OR as Stefan suggested having a 2 step process to convert to json.
Hope this helps.
Thanks
Mark
Mark
Right now I am just inquiring if this is possible and from your posts (THANKS), It appears that it is possible,
Frank
Good luck Frank,
Here is an example of the javascript I use in an extension to post json.
Mark
////////////////////////////////////////////////////////////////////////
function postData(webServiceUrl, obj,listoffiles) {
$.support.cors = true;
var Id=12;
$.ajax({
// crossDomain:"true",
type: "POST",
url: webServiceUrl,
data: '{"qvDataTable":' + JSON.stringify(obj) + '}',
contentType: "application/json; charset=utf-8",
timeout:"1728000",
dataType: "JSON",
ProcessData : "false",
xhrFields: { withCredentials: false},
success: function (msg) {
if(listoffiles.length==0)
{
$("#filelist").html("<B>No Files have been selected!</B>");
}
else
{
$("#filelist").html("<B>Changes have been saved.</B>");
doc.SetVariable("images_selected","updated");
}
$("#dialog-message" ).dialog({ hide: { effect: "explode", duration: 1000 } });
//selectedlist
//Update variable so know images have been updated
},
error: function (xhr, ajaxOptions, thrownError) {
switch (xhr.status.toString()) {
case "404":
alert('Error 404 posting the data to the webservice!\n\nCould not find webservice at Url ' + _this.WebserviceUrl);
break;
default:
alert('Error posting the data to the webservice:\n\n' + 'Error Status: ' + xhr.status + '\nError Status: ' + xhr.statusText);
break;
}
}
});
}
}, false);
}