Changes to serializer to make valid JSON strings when non-array elements
present