How to check empty element in json
问题 Is there any way in scala/java to evaluate if all items in a JSON are not empty? I would like to have a validator, avoiding to have items in a json with empty values like: [{"elem1":"","elem2":"","elem3":"a"}] Where the first two elements are empty. 回答1: Using Play JSON: import play.api.libs.json._ def hasEmptyValue(json: JsValue): Boolean = { json match { case _: JsBoolean => false case _: JsNull => false // could also be true, depending on your definition case _: JsNumber => false case