Created 08-07-2019 08:26 AM
HI All,
does anybody know how to check if the content of the file is null or empty? (JSON for example)?
Thanks,
Nera
Created 08-07-2019 08:46 AM
Hi @Rosa Negra
I only have experience concerning JSON.
In my opinion it depends what the content looks like.
If the content of an empty JSON is [ ] the flowfile disappears when I do a SplitJson with JsonPath Expression value $.
If the content looks like this [ { } ] I check with RouteOnContent on this (^\[\{\}\]) and filter the file out.
Created on 08-07-2019 08:49 AM - edited 08-17-2019 04:18 PM
@ Justen my JSON file is being converted to null (file size iz 4bytes) after wrong JOLT is applied.
So, when I open the JSON it's litterally 'null'. There are no brackets.. just null.
Created 08-07-2019 08:55 AM
@Rosa Negra
In this case I would use RouteOnContent to check null and maybe additionally check filesize to be on the safe side.
Created on 08-07-2019 09:06 AM - edited 08-17-2019 04:17 PM
@Justen Thanks!
Created on 08-07-2019 09:05 AM - edited 08-17-2019 04:17 PM
Created 08-07-2019 06:53 PM
The above question and the entire response thread below were originally posted in the Community Help track. On Wed Aug 7 18:53 UTC 2019, a member of the HCC moderation staff moved it to the Data Ingestion & Streaming track. The Community Help Track is intended for questions about using the HCC site itself.
Created on 08-17-2020 12:10 AM - edited 08-17-2020 03:30 AM
To check null in JavaScript, use triple equals operator(===) or Object is() method. If you want to use Object.is() method then you two arguments.
1) Pass your variable value with a null value.
2) The null value itself.
To find the difference between null and undefined, use the triple equality operator or Object is() method.
To loosely check if the variable is null, use a double equality operator(==). The double equality operator can not tell the difference between null and undefined, so it counts as same. So if you want to strict check, then don't use a double equality operator. It will lead to misconclusion.