Tommy
4 years agoNew Contributor III
Checking for existence of an array in a mapper
Hello. Im looking for a way of dealing with JSON documents that are sometimes recognised as an array, and sometime not. In the below example, i need to manipulate the “message” element to remove cert...
- 4 years ago
You might be able to get around it by using the following expression in a mapper before trying to process the $messages value:
sl.ensureArray($messages)
This way, if it is a single object, it will be a single-entry array. If it is already an arrary, it simply passes through.