Survive bad data

We move the marshalling of the data higher in the loop so that we can skip the element if it cannot be converted to JSON