CURLOPT_POSTFIELDS.3: fix incorrect C string escape in example

- Escape inner quotes with two backslashes.

Two backslashes escapes the backslash for the man page and will show as
a single backslash.

eg: "{\\"name\\": \\"daniel\\"}" shows as "{\"name\": \"daniel\"}".

Closes https://github.com/curl/curl/pull/12588
This commit is contained in:
Haydar Alaidrus 2023-12-24 02:28:06 +07:00 committed by Jay Satiro
parent 296cb805cf
commit 9faeebca88

View File

@ -97,7 +97,7 @@ int main(void)
/* send an application/json POST */
curl = curl_easy_init();
if(curl) {
const char *json = "{\"name\": \"daniel\"}";
const char *json = "{\\"name\\": \\"daniel\\"}";
struct curl_slist *slist1 = NULL;
slist1 = curl_slist_append(slist1, "Content-Type: application/json");
slist1 = curl_slist_append(slist1, "Accept: application/json");