Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
MikeC-12
Contributor II
Contributor II

Parse JSON Column in Data Load Editor

I am loading data from a SQL server that has a json column in it.  I have not had any success doing this.  Here is what one of the fields looks like.

{"Frequency":"Monthly","Estimated_Hours_to_prepare":"3","Estimated_Hours_Per_Workday":""}

I have tried the following with no success

Select JSON_VALUE(ExtendedProperties, "$.Frequency") As Frequency
From SQLDB

Select *
From SQLDB s
 CROSS APPLY OPENJSON(s.ExtendedProperties)
WITH (Frequency varchar(100))

Labels (2)
5 Replies
SerhanKaraer
Creator III
Creator III

Hello Mike,

You can parse it with From_Field function.

JsonTable:
LOAD * INLINE [
JsonData
'{"Frequency":"Monthly","Estimated_Hours_to_prepare":"3","Estimated_Hours_Per_Workday":""}'
];

LOAD * From_Field(JsonTable, JsonData) (json, utf8, no labels);

 It does not work properly when JSON is nested.

I hope it solves your issue.

MikeC-12
Contributor II
Contributor II
Author

Sorry I am not able to get this work.  This is a partial of my current load script.  Can you share with me where I would place your code?  The JSON field from SQL DB is called ExtendedProperities.  Thank you

Load
   ItemID, 
   Description,
   ClosedDate,
   ExtendedProperities;

[WorkItems]:
   Select
      ItemID,
      Description,
      ClosedDate,
      ExtendedProperities
   From SQLDB;

SerhanKaraer
Creator III
Creator III

Load
   ItemID, 
   Description,
   ClosedDate,
   ExtendedProperities;

[WorkItems]:
   Select
      ItemID,
      Description,
      ClosedDate,
      ExtendedProperities
   From SQLDB;

LOAD * From_Field(WorkItems, ExtendedProperities) (json, utf8, no labels);
MikeC-12
Contributor II
Contributor II
Author

When I try doing what you suggested I get the following error:

The following error occurred:
Field not found
The error occurred here:
LOAD * From_Field(WorkItems, ExtendedProperities) (json, utf8, no labels)
CasperQlik
Creator
Creator

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!