user60422: While working with JSON parsing I noticed that the char type data string is written like this:
char json[] = "{\"sensor\":\"gps\",\"time\":1351824120,\"data\":[48.756080,2.302038]}"; 

Why there are (escapes) " ---" used in the code? Why can't we use the string normally?

user4143: 
Why there are (escapes) " ---" used in the code? Why can't we use the string normally?

Because escapes are required.
In C " means 'The start or end of a string', but \" means 'A double-quote character'.
There has to be a way to distinguish a double-quote character from a string delimiter so the compiler knows which is which. Without escapes your string would look like:
char json[] = "{"sensor":"gps","time":1351824120,"data":[48.756080,2.302038]}"; 

and the compiler would find the end of the string at the second ", and then a load of junk before it finds the end-of-statement ; character. It can't work out what sensor":"gps","time":1351824120,"data":[48.756080,2.302038]}" is supposed to be, since it isn't in the string, but after it.

60422: <p>While working with JSON parsing I noticed that the char type data string is written like this:</p>
<pre><code>char json[] = &quot;{\&quot;sensor\&quot;:\&quot;gps\&quot;,\&quot;time\&quot;:1351824120,\&quot;data\&quot;:[48.756080,2.302038]}&quot;; 
</code></pre>
<p>Why there are (escapes) &quot; ---&quot; used in the code? Why can't we use the string normally?</p>
 4143: <blockquote>
<p>Why there are (escapes) &quot; ---&quot; used in the code? Why can't we use the string normally?</p>
</blockquote>
<p>Because escapes are required.</p>
<p>In C <code>&quot;</code> means 'The start or end of a string', but <code>\&quot;</code> means 'A double-quote character'.</p>
<p>There has to be a way to distinguish a double-quote character from a string delimiter so the compiler knows which is which. Without escapes your string would look like:</p>
<pre class="lang-cpp prettyprint-override"><code>char json[] = &quot;{&quot;sensor&quot;:&quot;gps&quot;,&quot;time&quot;:1351824120,&quot;data&quot;:[48.756080,2.302038]}&quot;; 
</code></pre>
<p>and the compiler would find the end of the string at the second <code>&quot;</code>, and then a load of junk before it finds the end-of-statement <code>;</code> character. It can't work out what <code>sensor&quot;:&quot;gps&quot;,&quot;time&quot;:1351824120,&quot;data&quot;:[48.756080,2.302038]}&quot;</code> is supposed to be, since it isn't in the string, but after it.</p>
