String to JSON

Say you’ve loaded a text into a string and you’d like to convert all special characters such as accented ones ( á é ñ) to unicode escapes inside of the string so you can save it as a standard JSON string or file. Example: “Coca-Cola & Nestlé” to “Coca\u002DCola \u0026 Nestl\u00E9”