Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

How to check if JSON content is null (or empty)?

How to check if JSON content is null (or empty)?

Explorer

HI All,

does anybody know how to check if the content of the file is null or empty? (JSON for example)?


Thanks,

Nera

6 REPLIES 6

Re: How to check if JSON content is null (or empty)?

Rising Star

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.

Re: How to check if JSON content is null (or empty)?

Explorer

@ 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. 110204-1565167770957.png

Re: How to check if JSON content is null (or empty)?

Rising Star

@Rosa Negra
In this case I would use RouteOnContent to check null and maybe additionally check filesize to be on the safe side.

Highlighted

Re: How to check if JSON content is null (or empty)?

Explorer

@Justen Thanks!110230-1565168780528.png

Re: How to check if JSON content is null (or empty)?

Explorer

@ Justen i believe this is the answer:


110205-1565168722104.png


Thanks!

Re: How to check if JSON content is null (or empty)?

Community Manager

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.

Bill Brooks, Community Manager
Was your question answered? Make sure to mark the answer as the accepted solution.
If you find a reply useful, say thanks by clicking on the thumbs up button.
Don't have an account?
Coming from Hortonworks? Activate your account here