Skip to content

Iteration.ts json cleaning is problematic #5074

@PBJI

Description

@PBJI

Describe the bug

Image

Each file contains some javascript code:

Image

Which I am trying to use in the llm as an iterator value,

Image Image

but the json cleaning causes removing of all escapes that results into error at JSON.parse() line, causing this error with iterator and bubbling up:

Image

Proposed solution:

const safeParseJson = (str) => { try { return JSON.parse(str) } catch { // Try parsing after cleaning return JSON.parse(str.replace(/\\(["'[\]{}])/g, '$1')) } } const iterationInputArray = typeof iterationInput === 'string' && iterationInput !== '' ? safeParseJson(iterationInput) : iterationInput;

To Reproduce

Put a json array that contains stringified codes into iterate with iterator using custom javascript function

Expected behavior

Iterator should have parsed the json and given values to node inside

Screenshots

No response

Flow

New Frontend Team Agents.json

Use Method

None

Flowise Version

v3.0.5

Operating System

Linux

Browser

Firefox

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions