Bug: Prompting for JSON output and then response appending curly brace after the array

Using either the API or Studio, I ask Google Gemini 1.5 Flash to “return all extracted objects as a valid array of valid JSON objects”. The response is an array of objects with a curly brace appended to the end of the JSON string e.g. “ }”. This string is not parsable and throws errors in my code. What’s worse is that the curly brace is appended sometimes.

const generationConfig = {
temperature: 1,
topP: 0.95,
topK: 40,
maxOutputTokens: 8192,
responseMimeType: “application/json”,
};

Anyone know a fix for this? Gemini Pro doesn’t seem to have this issue with the same prompt.

Hi @Balraj_Chana ,

Welcome to the forum !
Sorry for the late response.
I hope this issue is fixed now. Please try from your end & let us know if this issue persists.