Fixed infinite loop for serializing 'arrays' to JSON