Welcome to the Make community!
Most of the time, you cannot directly map variables containing text content into another JSON string without escaping them, as the variable might contain characters that have a special meaning in JSON.
Special characters in a value like these needs to be specified as a “literal” character (instead of a special metacharacter), otherwise they make the whole JSON invalid when you map the variable value when creating another JSON string.
You can escape string variables by passing the text into the JSON “Transform to JSON” module —
Transforms any object to JSON.
Then, you can map the output of the “Transform to JSON” module into your JSON string. (Do note that when using the “Transform to JSON” module, the output should already contain the double quotes " "
around your text, so when you map this output into your JSON, you should not need to wrap another pair of double quotes around it.)
Alternatively, you can use the built-in function replace
to replace those special characters with their escaped versions, as discussed here.
For more information on escaping JSON strings, see: Understanding JSON Escape: A Comprehensive Guide
Hope this helps! Let me know if there are any further questions or issues.
— @samliew