How do I provide Agent AI example JSON without causing "Single '{' in template" error

I am trying to provide the Agent AI a formatted example of JSON output for structure. As soon as I include a '{'in the system prompt I get an error "Single '{'in template"error. I have to have the '{'in there as that is valid JSON. Any insights into maybe stringify the JSON array to inject into the prompt but still seem to be running into the same error.

Here is an example of the JSON I am trying to inject into the System Prompt

const example1 = {
“data”: [
{
“Item1”: “This is a test”,
“Somedata”: {
“Frog”: 6,
“Cat”: 7,
“Dog”: 9
}
}
]
};
return example1;

[email protected]/
No database
Passing a JSON array into an Agent AI node / system prompt
Running N8N alone cause the error

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

EDIT: after replying i tested by copy and pasting your JSON and the problem is your quote character is incorrect. It would be nice if n8n intelligently fixed this for you, but it seems to require the correct quote char.

replace all of you quotes with " and that will fix it

Hi @DecodingSand . Where are you trying to add this JSON? Directly into the prompt or into the “Structured Output Parser” Node?

Unless you are in the code node, setting the json to a variable won’t work, you will need to just write it out in plain text OR save the json ealier in the workflow then access it from a variable with an expression, like below. Since it’s converting to a string you will need to stringify it.

@liam Thanks. I reworked the original Agent Ai code to your hinted Basic LLM Chain node with a Structured Output Parser and it worked great. I did not know about the Basic LLM Chain node and the Structured Output Parser worked together yet. Appreciate your prompt reply.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.