I am taking a big JSON as input, and rendering a smaller JSON output.
The problem is that the JSON input is not consistent, and some fields are sometimes missing.
Now I have to check for null and empty list to avoid errors during rendering, and the checks becomes repeating and long:
#{if _.metadata && _.metadata.genres && _.metadata.genres.size() > 0}
"genre": ${_.metadata.genres.get(0)},
#{/if}
Is there a smarter way to check if an item exist or not?
1 Answer