[SOLVED] Functions question...when to use double vs single quotes?
Posted: Wed Jun 24, 2020 4:15 pm
I've always used double quotes when dealing with variables in functions. Like this function %my_usr_var% = $left($proper($alrep("%s_original_name%","")),28) to shorten and remove spaces etc from filenames in a populate variable node.
Ran into some issues with using the $jsonencode function to create a JSON friendly version of %s_error%. For the below examples assume "%s_error%" is equal to Youtube-dl@HOSTEN250-04: Could not download: "swarm shake 2019.mp4"
My initial attempt was this
%json_error% = $jsonencode("%s_error%") but the value of %json_error% became $jsonencode("Youtube-dl@HOSTEN250-04: Could not download: "swarm shake 2019.mp4"") which is not JSON friendly.
When I changed it to single quotes
%json_error% = $jsonencode('%s_error%') the value of %json_error% became Youtube-dl@HOSTEN250-04: Could not download: \"swarm shake 2019.mp4\" which is correct.
Looking for insight on when to use single ' quotes vs double " quotes. I want to go through my variable nodes and make sure they are correct.
Ran into some issues with using the $jsonencode function to create a JSON friendly version of %s_error%. For the below examples assume "%s_error%" is equal to Youtube-dl@HOSTEN250-04: Could not download: "swarm shake 2019.mp4"
My initial attempt was this
%json_error% = $jsonencode("%s_error%") but the value of %json_error% became $jsonencode("Youtube-dl@HOSTEN250-04: Could not download: "swarm shake 2019.mp4"") which is not JSON friendly.
When I changed it to single quotes
%json_error% = $jsonencode('%s_error%') the value of %json_error% became Youtube-dl@HOSTEN250-04: Could not download: \"swarm shake 2019.mp4\" which is correct.
Looking for insight on when to use single ' quotes vs double " quotes. I want to go through my variable nodes and make sure they are correct.