This is a bit tricky: Since we are streaming the elements to the unparser,
it will receive a DIArray element, but the length of that DIArray element at the
time it is received, will probably be 0 because the child elements (not even
one of them) will have been pulled yet. So we cannot just measure how big the array
is and iterate that many times. Rather, we have to iterate until we come to
an End(DIArray) event.
This requires the ability to look ahead into the input stream by 1, see if it
is EndArray, and if so consume it and end the iteration.
This is a bit tricky: Since we are streaming the elements to the unparser, it will receive a DIArray element, but the length of that DIArray element at the time it is received, will probably be 0 because the child elements (not even one of them) will have been pulled yet. So we cannot just measure how big the array is and iterate that many times. Rather, we have to iterate until we come to an End(DIArray) event.
This requires the ability to look ahead into the input stream by 1, see if it is EndArray, and if so consume it and end the iteration.