/** * 尝试从字符串中提取JSON对象 */ export const getJsonFromString = (str: string) => { try { const jsonMatch = str.match(/```json\s*([\s\S]*?)\s*```/); if (jsonMatch && jsonMatch[1]) { return JSON.parse(jsonMatch[1]); } } catch (error) {} return null; };