JSON parse error after Gemini AI module — “Source is not valid JSON”

Hi everyone,
I’m building an automation that classifies Outlook emails using Google Gemini AI and then parses the AI output with a Parse JSON module.

Gemini correctly returns a JSON block like this in the output:

```json
{
  "grupo": "Filipinas",
  "categoria": "Facturación y cuentas"
}

However, when I try to parse it, I always get this error:

DataError — Source is not valid JSON

I already tried cleaning the output using this formula inside the JSON string field:

replace( replace( 248.Result; “json”; “” ); “”; “” )

…but the error persists.

Gemini’s output in the operation log looks perfectly valid JSON, and I’ve double-checked that the Data Structure has two text fields:
grupo (Text) and categoria (Text).

Has anyone faced this issue with Gemini outputs containing triple backticks?
Any idea what could still make Make think the JSON source is invalid?

Hey Cristian,

you don’t need the double quotes inside the replace function. Instead of “‘‘json” it should be just ‘‘‘json for example. Then if you are trying to delete something use the tag {{emptystring}} and not double quotes with nothing between them.

2 Likes

thankssss now it works!!!

I am running into a similar situation. Even though I am using the script to strip out the markdown, for some reason it is not stripping out ‘json’. It is getting rid of the ``at the start and the`at the end but it won’t remove the json after the first``.

Here is the source:

Maybe I have been staring at this for too long? help!

Looks like you have empty spaces around ```json

2 Likes

I stared at it too long. That was it. Thank you @Stoyan_Vatov