Although three years down the line for this thread, it looks to be the solution to my issue - unwanted newlines in JSON. In my case, they aren't being entered by users but are injected by MachForm when the values of checkbox fields are included in the JSON. Still, I assume this approach would remove them and allow successful parsing of the JSON at the receiving end.
Unfortunately there isn't enough context in the approach described to help me to implement this. I assume, unless corrected, that the function definition goes into the main body output and that the fields with potential newlines are wrapped in the function call. But what is the relevance of the 'array_walk' reference? Does this form part of what needs to be implemented, and if so where does it go? And is there any need to reference 'includes/helper-functions.php' in my "Send Form Data to Another Website" definition?
I'm using a MachForm hosted environment, rather than self hosted as the OP had. I don't know if that makes any difference.
Thanks,
Jerry