Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Modernize Your QlikView Deployment webinar, Nov. 3rd. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Creator III
Creator III

Load Data by Script with JSON

Hello,

I have a file with the following data with JSON format:

[{"id":"500","program":"prog003","number":"333525","datetime":"2017-01-03 15:45:15","zone":"north","amount":"100"}, {"id":"501","program":"prog003","number":"333526","datetime":"2017-01-03 15:48:30","zone":"north","amount":"300"}, {"id":"502","program":"prog003","number":"333527","datetime":"2017-01-03 17:25:23","zone":"south","amount":"150"}]

Do you know how can I load the data in a table by script? (Preferably with no connectors)

Thank you!!!

18 Replies
Highlighted
Master II
Master II

1. As per my knowledge this is not possible. The JS macro needs to know the information about the tablename, which was missing in your case.

2. You could create an Inlinetable in which you load all the different data_fin.json files by creating a loop.

hope this helps

Highlighted
Master II
Master II

Hi,

I think i found a workaround.

just add an arrayname in maintable and use your json2csv function in Resident Load.

see attached sample.

hope this helps

View solution in original post

Highlighted
Contributor II
Contributor II

@franky_h79

1. What is the purpose of adding DummyField?

2. Where and How is the Jscript for json2csv function loaded?

Thanks for guiding.

Highlighted
Master II
Master II

1. In order to get this macro work without having an arrayname in your json file you will have to generate this

missing arrayname. in this case i just named it DummyField. If you have an arrayname in your json file then you dont have to use the preload and the name "DummyField" but your arrayname like:

json2csv(@1,'PutYourArrayNameHere') as data_csv


2. Look inside the module (Tools-->Edit Module). there you will find the jscript function which is called inside QV script. Make sure that the settings in your module on the left side are correct

hope this helps

Highlighted
Contributor
Contributor

Hi Frank,

thanks for your solution with the Json_253827_Loop.qvw, but i have problem to load my Json file.

Can you help me to load this JSON file?

The format is:

{

  "shocks": [

    {

      "timestamp": 1529278573,

      "truckNr": "FN539599",

      "shipToPartyNr": "59179278",

      "intensityHorizontal": 484,

      "intensityVertical": 132,

      "shockLevel": 2,

      "truckReaction": "show_on_display"

    },

    {

      "timestamp": 1529278684,

      "truckNr": "FN539599",

      "shipToPartyNr": "59179278",

      "intensityHorizontal": 209,

      "intensityVertical": 55,

      "shockLevel": 1,

      "truckReaction": "save"

}

  ]

}

Thanks!

Highlighted
Master II
Master II

Hi Niels,

see attached file.

NOTE: You will have to remove the linebreaks in your json file.

Notepad++ --> Edit -> Line Operations -> Join Lines


or you will have to join, concat the lines on QV script level what might be a little bit tricky.

hope this helps

Highlighted
Contributor
Contributor

Thanks for your help!

Highlighted
Contributor III
Contributor III

Highlighted
Contributor III
Contributor III