Last active
September 13, 2017 18:51
-
-
Save drexler/9e3d1b4badfe78b34b03a1f099a6013f to your computer and use it in GitHub Desktop.
Test for a property existence in a velocity template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
#set($flag = false) | |
#set($missing = "'""""'") | |
#if("'$input.json('$.aJsonField')'" != $missing) | |
"JsonFieldIsPresent": $input.json('$.aJsonField') | |
#set($flag = true) | |
#end | |
#if("'$input.json('$.aJsonField')'" == $missing) | |
#if($flag == true), #end | |
"JsonFieldIsMissing": true | |
#end | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment