How to check JsonNode value is empty or not : java

1.1k Views Asked by At

I want to check Jsonnode value is present or not, As shown below myObj is an input. in this name is a key and "" is a value. I want to check if I get "" value then it should be go in else part. I tried by using following code but its not working.

JsonNode myObj = {name:""};

JsonNode node = myObj.get("name");

if(node != null && !node.isNull()){

// do some things with the item node

} else {

// do something else

}
1

There are 1 best solutions below

0
On

Have you tried something like this:

node != null && !node.isNull() && node.textValue().isEmpty()