What are the functions of these backslashes in this sentence? http.POST("{ "hello ": "world "}");

Asked

Viewed 36 times

0

// start connection and send HTTP header and body
int httpCode = http.POST("{\"hello\":\"world\"}");
  • I think you should study "what is the function of the backslash?" and escape characters.

  • Specifically about JSON: The delimiter of a string in JSON always is ". As your string already uses " in the code, you need to use \" to escape the string that goes inside the quotes.

1 answer

4

These inverted bars serve to escape the next character, ie it will be understood literally as ", and not as closure of string.

Without these bars, the content within their function would be a string invalid.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.