Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Announcing the newest addition to the Qlik Community, Qlik Gallery! Learn More
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

Tags (1)
8 Replies
MVP
MVP

Re: File Type Output

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

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

markodonovan
Valued Contributor

Re: File Type Output

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

Partner
Partner

Re: File Type Output

Mark

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


Regards,

Frank

markodonovan
Valued Contributor

Re: File Type Output

Hi Frank,

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

Mark

Partner
Partner

Re: File Type Output

Mark

I need to export.

markodonovan
Valued Contributor

Re: File Type Output

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

Partner
Partner

Re: File Type Output

Mark

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

Frank

Highlighted
markodonovan
Valued Contributor

Re: File Type Output

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

}