I have below the JSON structure. In which I am trying to find the value based on jsonpath.
{
"business": {
"BusinessUnit": "78sdhja",
"PriorityType": "Scheduled",
"NoPhiScrubbing": "false"
}
}
Here, I am trying to get the business unit which can have any value like can be empty or null or any value. I have tried with the below example. But it didn't work.
"$.business.[?(@.BusinessUnit== /.*/)]";
Can anyone help me to with this?
If you are working with Spring based project. Go with JSR Validations
https://howtodoinjava.com/spring-mvc/spring-bean-validation-example-with-jsr-303-annotations/
https://beanvalidation.org/1.0/spec/
Above link will help
For Not null or empty you can use @NotNull @Empty while for any value validation you may use pattern for same.
In case value doesn't match, it throws MethodArgumentNotValidException
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.