Invalid JSON in Gemini 3.5 Flash

Since upgrading from 3.1 Flash to 3.5 Flash, I am getting Invalid JSON errors.

Unexpected token ‘;’, …“ndations”:; it is fo"… is not valid JSON"

stack: “SyntaxError: Unexpected token ‘;’, …“ndations”:; it is fo”… is not valid JSON
at JSON.parse ()

After I get the result from generateContent, I attempt to parse the result in JSON.parse(result.text) and get this error.

It is not for every request but perhaps 5% of them. What is going on here?

This is my prompt:
{
model: “gemini-3.5-flash”,
config: {
tools: [{ googleSearch: {} }],
thinkingConfig: {
thinkingLevel: “ThinkingLevel.MEDIUM”,
},
responseMimeType: “application/json”,
responseSchema: {
type: “Type.OBJECT”,
properties: {
primaryCategoryRecommendations: {
type: “Type.STRING”,
description:
“Concise recommendations for the primary user or customer input category.”,
},
secondaryCategoryRecommendations: {
type: “Type.STRING”,
description:
“Concise recommendations for the secondary operator or specialist input category.”,
},
itemizedListRecommendations: {
type: “Type.ARRAY”,
description:
“Recommendations, analysis, or strategic suggestions for each individual item provided in the source data.”,
items: {
type: “Type.OBJECT”,
properties: {
itemName: {
type: “Type.STRING”,
description:
“The unique name or identifier of the specific item being evaluated.”,
},
itemRecommendations: {
type: “Type.STRING”,
description:
“Tailored recommendations unique to this specific item.”,
},
},
required: [“itemName”, “itemRecommendations”],
},
},
},
required: [
“primaryCategoryRecommendations”,
“secondaryCategoryRecommendations”,
“itemizedListRecommendations”,
],
},
systemInstruction: “YOUR_ANONYMIZED_SYSTEM_INSTRUCTION_HERE”,
},
};