Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
microwin88x
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!!!

22 Replies
Frank_Hartmann
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

Frank_Hartmann
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

Anonymous
Not applicable

@franky_h79

1. What is the purpose of adding DummyField?

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

Thanks for guiding.

Frank_Hartmann
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

Anonymous
Not applicable

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!

Frank_Hartmann
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

Anonymous
Not applicable

Thanks for your help!

AAbarzua
Contributor
Contributor

Hola Frank, me podrías ayudar con esto. Tengo un json que la solución planteada no me procesa bien la información porque tengo un campo con subcampos? te envió json, me imagino que la solución va por una modificación en el script del modulo de QlikView, lo cual desconozco como se realiza. Desde ya mucha graxx Te adjunto json. Estare atento