N
Noman
Guest
So, trying to send a string to slack with some newlines in thar... and having trouble formatting the string correctly.
\n comes out as \\n in the string... I've tried separating it out as a character with single and double quotes... it always gives me more \\'s than I need and they are in the string.
The one thing that works is just hitting Enter in the code editor... which results in a properly single \... with an extra character. It ends up as \r\n ... which works fine for slack but results in horribly unreadable code.
What's the right way to put a newline in a string for JSON?
Here's a bit that ends with \\n's and doesn't work at all.
var slackreport, str;
slackreport = ds_map_create();
ds_map_add(slackreport, "text", "thing \n thing");
str = json_encode(slackreport);
get[0] = http_post_string("http:/stuff", str);
\n comes out as \\n in the string... I've tried separating it out as a character with single and double quotes... it always gives me more \\'s than I need and they are in the string.
The one thing that works is just hitting Enter in the code editor... which results in a properly single \... with an extra character. It ends up as \r\n ... which works fine for slack but results in horribly unreadable code.
What's the right way to put a newline in a string for JSON?
Here's a bit that ends with \\n's and doesn't work at all.
var slackreport, str;
slackreport = ds_map_create();
ds_map_add(slackreport, "text", "thing \n thing");
str = json_encode(slackreport);
get[0] = http_post_string("http:/stuff", str);