I'm using CURL to send JSON data. Here is an example:
mycomputer$ curl -H "Content-Type: application/json"
-d "{ "some_string": "Hello mom it's me!" }"
"http://localhost:3001/api_v2/blocks/42af6ab04d9d9635a97f8abec14ed023?api_key=fe5cf0d86af27c086ab5cd4d0eab6641"
How can I escape the contents of any value for some_string?
For example if someone wants to put in the string Abe Lincoln's favorite character is the backslash \. He said "I love the \ and single quotes like ''". how can I escape this while using curl?
I think I need to do the following:
If the string contains a
"escape it with a triple backslash\\\".If the string contains a
'escape it doesn't need escaping'.- If the string contains a
\escape it with a triple backslash\\\\.
Are there any characters I am forgetting?