How to convert text file to json?

Describe the problem/error/question

How do I convert a text file into json? here’s the text file https://pastebin.com/raw/DymtuBEy

What is the error message (if any)?

The ‘JSON Output’ in item 0 does not contain a valid JSON object

Please share your workflow

Share the output returned by the last node

Information on your n8n setup

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

Are you able to read from disk? Any errors?

Yes it can read from disk

No issue

I am not sure what is your problem

Third node is already in json. Perhaps you can explain in detail what you are trying to implement

I’m trying to convert text into a vaild json object so I can later extract specific fieldnames

Hi @Ruriko
Its separate JSON objects placed one after another, which is not a single valid JSON document.

The safest conversion rule is: separate each object with a comma.

Hi @Ruriko Use an AI Agent and give it good amount of instructions and a structured output incase if you want, and then use some cheap model as this task should not require much reasoning, so for now just go along with Groq and choose a model and there dump your text file data into your AI agent USER PROMPT, and give it a good system prompt on what you want, and there add a structured output parser with your requirement on how you want your valid JSON to be. It would really work.