Can't apply json_decode to inputs...?
Options
![Erin](https://us.v-cdn.net/6037124/uploads/userpics/0K8NT74W8WD8/nYA4TPTOVADTB.jpeg)
Erin
Member ✭
My app has a simple messaging feature. It turns out that if a user puts line breaks in their message, I get the error "Error parsing JSON: Control character error, possibly incorrectly encoded"
I tried replacing "\n" with " " before decoding, but still got the error. In "Run & Debug", I rewrote the message totally from scratch in case there were invisible control characters (apparently that's a thing?). It still failed as soon as I put in "\n".
I'm successfully decoding "\n" in other parts of the app. Why does it give me trouble when trying to apply that to an input?
Tagged:
Answers
-
For anyone encountering the same issue:
- I saved the input as a new variable (sms_body)with the json_encode filter.
- For a postscript I needed to add to the end, I saved the text in a variable like this: "\n\nReply STOP" (include the quotation marks in the text!).
- In my API request, I put in the new variable with the json_encode filter, then concatted the postscript with its own json_decode:
Categories
- All Categories
- 53 ? Announcements
- 47 ? Releases
- 37 ? Welcome
- 983 ? Help! I'm a Noob
- 125 ? No-Code Front-Ends
- 633 ? Working with APIs
- 439 ? Transforming data
- 126 ? Connect Xano to ...
- 50 ?? Find an Expert
- 348 ❓Other questions
- 35 ? Security
- 22 ✂️ Snippets
- 19 ? Showcase
- 7 ?️ Xano Chatter
- 62 ? Video Tutorials
- 171 ? Request a feature
- 229 ? Report a Bug
- 19 ? Templates & Extensions
- 7 ? Feedback