Function to strip out characters that break JSON

Anyone have regex or a function for stripping out characters from API calls that cause json to break?

I’m looking for a easy way to escape characters on all API text fields we post to other tools

Maybe bubble could add as a :: formatting option?

image

Folks with same request…
http://forum.bubble.io/search?q=json%20remove%20break

In the past when I’ve had this problem, I’ve used 2 Find and Replace commands in succession of one another, like so…

The first one looks for a backslash, the second one looks for double quotes.
Each of those are escaped by adding a backslash before it.

That’s done the trick for me and I’ve not needed anything else. You could try it and see if it helps.

2 Likes

Yes, this is also what we’re doing to 50-100 fields in our app where we’re posting data to external endpoints. /n is another to escape which in Find/Replace is an actual “return”. Hardcoding /n doesn’t work.

@kramwe - I know it’s a year after you made this post but was wondering how you searched and replaced for the line breaks to make sure they didn’t get into the JSON file. I tried searching for ‘/n’ and replacing with ‘/n’ but that didn’t seem to work.

Thanks in advance for any suggestions.

just press return in top “find” box. will look like nothing.