Fix error when using JSON serializer and converting integer types to smallest possible type.