attributes['content']; //判断是否json格式 if ($this->isValidJson($content)) { $content = json_decode($content, true); } return $content; } /** * 获取推广员配置内容 * @author 唐远望 * @version 1.0 * @date 2025-09-05 * @return string */ function isValidJson($string) { if (!is_string($string) || empty($string)) { return false; } // 尝试解码 $result = json_decode($string); // 检查解码错误 if (json_last_error() !== JSON_ERROR_NONE) { return false; } // 确保解码后不是null(除非原始JSON就是"null") if ($result === null && $string !== 'null') { return false; } return true; } }