Forum Discussion

Tommy's avatar
Tommy
New Contributor III
4 years ago
Solved

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...
  • koryknick's avatar
    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.