Ensures a JSON string is safe for the given serializer.
fun <T : Any> String.serializerSafe(serializer: KSerializer<T>?): String