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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
VictorFaure
Contributor II
Contributor II

Splitting JSON array into objets (each in a row)

Hello,

I'm currently working on requesting a paginated API which returns data into an array containing several objects like so:
"array_elem": [{"prop1": "val1", "prop2": "val2"}, {"prop1": "val3", "prop2": "val4"}]
What I want to do finally is to merge the arrays I receive from the different pages into one big array.
What I'm struggling with is splitting the above array into 2 rows containing json objects like this:
row1: {"prop1": "val1", "prop2": "val2"}

row2: {"prop1": "val3", "prop2": "val4"}

instead I get
["val1", "val2"]

["val3, "val4"]

And when merging into the big array it becomes 2D array and we lose the properties' names.

Here is my tExtractJSONFields config:

VictorFaure_0-1760625871772.png

 

Labels (3)
1 Solution

Accepted Solutions
Shicong_Hong
Employee
Employee

@VictorFaure 

Hello!

You can read the data as a string, then use Java code to intercept the substring, and finally, use the tNormalize component to split the string into multiple rows.

2025-10-22_11-03-15.png2025-10-22_11-02-55.png2025-10-22_11-02-33.png2025-10-22_11-01-46.png

Java code on tJavaRow_1:

//Code generated according to input schema and output schema
output_row.body = (input_row.body.substring(input_row.body.indexOf(":")+1)).replaceAll("\\[", "").replaceAll("\\]", "");
output_row.body=output_row.body.replaceAll("\\}, \\{","\\}; \\{");

 

Hope it helps you!

Regards

Shicong

View solution in original post

2 Replies
Shicong_Hong
Employee
Employee

@VictorFaure 

Hello!

You can read the data as a string, then use Java code to intercept the substring, and finally, use the tNormalize component to split the string into multiple rows.

2025-10-22_11-03-15.png2025-10-22_11-02-55.png2025-10-22_11-02-33.png2025-10-22_11-01-46.png

Java code on tJavaRow_1:

//Code generated according to input schema and output schema
output_row.body = (input_row.body.substring(input_row.body.indexOf(":")+1)).replaceAll("\\[", "").replaceAll("\\]", "");
output_row.body=output_row.body.replaceAll("\\}, \\{","\\}; \\{");

 

Hope it helps you!

Regards

Shicong

VictorFaure
Contributor II
Contributor II
Author

Hello and thanks for the reply !

I usually dislike using regex replace on json strings but it seemed to be the only solution in this case, I have done a variation of the setup you show here and it works for me (I remove the square brackets and replace with broken pipe as separator in case of semicolon in my data).

Thanks again