Are there any way to filter out nulls from result?
See original GitHub issueHello, I have the following JSLT file:
{
"formId": "Company",
"fieldValues":
[
{
"name": "CompanyName",
"value": {
"en_US": string(.data.companyName)
}
},
if (contains("Android", array(.data.platforms)))
{
"name": "PlatformAndroid",
"value": {
"en_US": true
}
},
if (contains("IOS", array(.data.platforms)))
{
"name": "PlatformIOS",
"value": {
"en_US": true
}
},
if (contains("MicrosoftStore", array(.data.platforms)))
{
"name": "PlatformMicrosoftStore",
"value": {
"en_US": true
}
},
{
"name": "Pack",
"value": {
"en_US": string(.data.pack)
}
}
]
}
But the fieldValues array contains nulls if there are no platforms checked because of the behavior of if statement.
Before this solution, I tried to iterate over .data.platforms but I couldn’t because in this case the result will be a separated array. After that I tried to define a new function for that, but I couldn’t.
Do you have any idea? Thank you.
Issue Analytics
- State:
- Created 2 years ago
- Comments:16
Top Results From Across the Web
How to filter out null values - sql - Stack Overflow
The results of my SQL query include null values. How do I filter out null values? ... Please add a few rows of...
Read more >How to SELECT Records With No NULL Values in MySQL
There you have it; a simple comparison operator that can be used to filter out any and all NULL values in your records....
Read more >How to hide null values from a Tableau filter - TAR Solutions
1. Create a set on the Dimension containing the filter values. · 2. Exclude the Null (or other unwanted values) from the set...
Read more >How to Filter Rows without NULL in a column | LearnSQL.com
To display records without NULL in a column, use the operator IS NOT NULL. You only need the name of the column (or...
Read more >Spark Filter Rows with NULL Values in DataFrame
In many cases NULL on columns needs to handles before you performing any operations on columns as operations on NULL values results in...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Thank you Guys, you are great! I’m testing all approaches as well.
Hi @shark300
Follow the solution. Basically you transform all content in a array, then you print (with loop “for”) the elements != null
Jslt:
{ “formId”: “Company”, “fieldValues”: [for(array( [ { “name”: “CompanyName”, “value”: { “en_US”: string(.data.companyName) } }, if (contains(“Android”, array(.data.platforms))) { “name”: “PlatformAndroid”, “value”: { “en_US”: true } }, if (contains(“IOS”, array(.data.platforms))) { “name”: “PlatformIOS”, “value”: { “en_US”: true } }, if (contains(“MicrosoftStore”, array(.data.platforms))) { “name”: “PlatformMicrosoftStore”, “value”: { “en_US”: true } }, { “name”: “Pack”, “value”: { “en_US”: string(.data.pack) } } ] )). if( . != null)] }