Skip to content

Comments

Fix JSON parsing bug.#75

Merged
jseyfried merged 1 commit intomainfrom
fix-json-parsing-bug
Feb 13, 2026
Merged

Fix JSON parsing bug.#75
jseyfried merged 1 commit intomainfrom
fix-json-parsing-bug

Conversation

@jseyfried
Copy link
Contributor

Currently, if LLM outputs "C:\\my\\path" (which is correct JSON encoding of C:\my\path), taskgen returns "C:\\\\my\\\\path" (i.e. C:\\my\\path). Also, if LLM outputs "C:\\test\\path", taskgen returns "C:\\\test\\\\path" (not "C:\\\\test\\\\path").

This was caused by parsing strings from JSON using match[1:-1] followed by remove_unicode_escape instead of just json.loads(match).

Script to reproduce:

import taskgen
from taskgen.base import strict_json

LLM_OUTPUT = r"""```json{"###Key###": "\\a\\n\\t\\b"}```"""
print("LLM output:", LLM_OUTPUT)

def chat(*args, **kwargs):
    return LLM_OUTPUT

taskgen.base.chat = chat
print("taskgen output:", strict_json('', '', {"Key": "type: string"}))

Before PR: taskgen output: {'Key': '\\\\a\\\n\\\t\\\\b'}
After PR: taskgen output: {'Key': '\\a\\n\\t\\b'}

@jseyfried jseyfried force-pushed the fix-json-parsing-bug branch from 02cff3d to fd8e914 Compare February 13, 2026 06:39
@jseyfried jseyfried merged commit 6335a92 into main Feb 13, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants