.toJsonString()
I see is using quite a lot of `.replace()` functions when sending a JSON request to an api.
it may look like this:
```
"{{ $json.output
.replace(/\r?\n|\r/g, ' ')
.replace(/"/g, '')
.replace(/[“”]/g, '') // removes curly double quotes
}}"
```
Just wanted to let you know that in most cases, if not all, you can use the single (simple) function: `.toJsonString()` like this:
```
{{ $json.output.toJsonString() }}
```
Note that it also adds the outer quotes, so instead of, for example `"prompt": "{{ $json.output....}}"`, you should use `"prompt": {{ $json.output.toJsonString() }}`
8
3 comments
Zohar Stolar
3
.toJsonString()
AI Automation Society
skool.com/ai-automation-society
A community built to master no-code AI automations. Join to learn, discuss, and build the systems that will shape the future of work.
Leaderboard (30-day)
Powered by