Fix bug when using JSON as serializer