Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
root
Creator II
Creator II

Check JSON for empty values

How can I validate if the JSON object is not empty? Currently, I am processing the data[] array and it is inserting values in DB. If its a blank, then, it inserts a NULL. How can I achieve this? 

 

Correct JSON:

{
	"RESULT_1": {
		"data": [
			["0", null, "12345", "other"],
			["1", "a", "54321", "MA"],
			["0", null, "76543", "RI"]
		]
	}
}

Empty JSON:

 

{
	"RESULT_1": {
		"data": [		]
	}
}

 

 Thanks!

Labels (3)
4 Replies
Anonymous
Not applicable

Hello,

Have you tried to replace your empty/null field with "Null" string?

Such as:

output_row.output = input_row.output.replaceAll(",\"[a-zA-Z][a-zA-Z]*\":\\[\\]", "Null"); in tJavaRow.

Best regards

Sabrina

 

root
Creator II
Creator II
Author

@xdshi:
Thanks for your reply. So, this will essentially check [] and if it does not contain anything, mark it null?

Anonymous
Not applicable

Hello,

It will check empty values in your JSON file.

Best regards

Sabrina

root
Creator II
Creator II
Author

Thank you!