Solved
Forum Discussion
koryknick
4 years agoEmployee
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.
ptaylor
4 years agoEmployee
Yes, Kory is correct: it’s standard practice to use sl.ensureArray() on such elements. This is particularly the case when dealing with documents that were converted from XML. Unlike JSON, XML doesn’t have an explicit syntax for arrays, so there’s ambiguity when converting an element with one child – it may or may not represent an array with one element.