Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Our next Qlik Insider session will cover new key capabilities. Join us August 11th REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
fcecconi
Partner
Partner

File Type Output

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

8 Replies
swuehl
MVP
MVP

I don't think that's supported by the API.

You might consider exporting your data to csv and then converting to JSON.

markodonovan
Specialist
Specialist

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

http://techstuffy.tv

fcecconi
Partner
Partner
Author

Mark

The client wants to use their own visualization.  So all they really want to use is the Qlik engine.


Regards,

Frank

markodonovan
Specialist
Specialist

Hi Frank,

Does your data model need to contain the JSON or do you need to export the JSON to a file ?

Mark

fcecconi
Partner
Partner
Author

Mark

I need to export.

markodonovan
Specialist
Specialist

Hi Frank,

If you are using Ajax you could still create an extension send the data elsewhere and changing this to json is possible:

http://www.qlikblog.at/1798/posting-data-from-qlikview-to-other-systems-using-the-ajax-client-and-ex...

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

http://techstuffy.tv

fcecconi
Partner
Partner
Author

Mark

Right now I am just inquiring if this is possible and from your posts (THANKS),  It appears that it is possible,

Frank

markodonovan
Specialist
Specialist

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);

}