MACRO: Escape a String for JSON

There may be a built-in way to do this, but I couldn't find it.

This macro will escape a JSON string, either on the clipboard, or via a passed parameter. Example:

Input:

Called "JSON Escape String" without passing a parameter,
so the macro escaped this text, which was on the clipboard.

Output:

Called \"JSON Escape String\" without passing a parameter,\nso the macro escaped this text, which was on the clipboard.
Click for Macro Image

image

 

You can call it like this and it escapes what's on the clipboard:

image

 
Or like this, and the result is returned in Instance_Result:

image

 
JSON Escape String.v1.0.kmmacros (16.2 KB)

It includes a couple of example macros.

1 Like

Thank you very much. I was trying a lot before i found your Macro. I works fantastic in my Use Case. Thank you Holger

1 Like