Add JSON escape expression

The idea is:

If I try to save a very complex string in a JSON object (e.g. html document) I will often get an error JSON parameter needs to be valid JSON [item 0]

Can you add an expression function that will escape any invalid characters from JSON? e.g. here is an online tool that does it for me. MDN docs on JSON object specs

My use case:

I need to store HTML docs in fields and then insert them into HTTP requests JSON body.

I think it would be beneficial to add this because:

Escaping characters is hard to do manually, so please add a convenience function to accomplish it.

Are you willing to work on this?

yes, if you help me setup dev environment

You can use the existing .toJsonString() or just JSON.stringify

E.g. this JSON {"count":1,"name":"Test n8n"} becomes {\"count\":1,\"name\":\"Test n8n\"}

1 Like