Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
master_t
Partner - Creator II
Partner - Creator II

Parsing JSON in QlikSense?

Hi everyone

Let's say I have a json string in a QlikSense script, like:

let x = '{"name":"foo", "surname":"bar"}';

Can I read a specific value from it, like for example the "name" value, without having to manually manipulate the string? In other words, is there a JSON parser in QlikSense?

8 Replies
petter
Partner - Champion III
Partner - Champion III

There is a JSON parser in Qlik Sense although it hasn't been documented. Maybe that is because it only handles "flat" JSON files and not nested structures - I don't know.

It can not be invoked on variables but it can read JSON from files.

petter
Partner - Champion III
Partner - Champion III

An example with your specific JSON in a file called test.json would look like this:

LOAD

    name, surname

FROM [lib://DATA/test.json] (json)

;

master_t
Partner - Creator II
Partner - Creator II
Author

Unfortunately, reading nested structures is what I need...

petter
Partner - Champion III
Partner - Champion III

It is also possible to load from an INLINE table like this:

SOMEJSON:

LOAD * INLINE [

json_field

{"name":"foo", "surname":"bar"}

{"name":"barry", "surname":"fool"}

{"name":"fu", "surname":"bal"}

] (txt,delimiter is \t);


PARSED_JSON:

LOAD

  name,

  surname

FROM_FIELD

  ( SOMEJSON,json_field ) (json);





2018-06-08 15_32_51-Microsoft Edge.png

petter
Partner - Champion III
Partner - Champion III

Well then you will have to resort to much more load script scripting... It can become pretty complicated if you want want to be able any type of nested nested structure. But if it is a predefined and well-defined static structure with very few levels it would absolutely be feasible.

RickWild64
Partner - Creator
Partner - Creator

Hi Petter,
How did you find out about this feature?
Cheers,
Rick
CasperQlik
Contributor III
Contributor III

I get the following error when I use the From_Field function:

CasperQlik_0-1695719972461.png

 

This is my code:

 

CasperQlik_1-1695720069255.png

Any help is appreciated!

 

harshal852001
Contributor II
Contributor II

Hi Petter,

 

Do you have any solution data load "Qliksense "read  the SQL table having  couple of fields having various JSON format values ,what is appropriate way to LOAD in model.

 

Kindly suggest if you aware

Thanks

Harshal